I know that in PHP we can create an object using new ClassName, as well as using new ClassName()(note the brackets). Is there any difference between the two?
new ClassName
new ClassName()
No, no difference. If you do not need to pass parameters to the constructor, the brackets will be superfluous.
No, no difference.
() required only if you need to pass parameters to the constructor, otherwise you could skip it.
()
Source: https://habr.com/ru/post/1529175/More articles:Use a Symfony 2 component in a project other than Symfony? - phpUnable to use macro combination class in C ++ - c ++Python mockito - Mocking a class that is created from the function being checked - pythonSymfony 1.4 совместимая система перевода I18N? - phpзапоминание пользователя после входа в систему google api (когда пользователь "обновляется" или переходит на другую страницу на моем сайте) - javascriptJS: How to add negative numbers in javascript - javascriptSeparate mobile views and layouts for mobile pages - ruby-on-railsSplit string value in array of arrays in Python - python.split () regex with sliding brackets doesn't work in IE8 - javascriptregex match () works in FF / Chrome, but not IE 8 - jqueryAll Articles