The difference between creating an object using `new ClassName` and` new ClassName () `in PHP

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?

+4
source share
2 answers

No, no difference. If you do not need to pass parameters to the constructor, the brackets will be superfluous.

+7
source

No, no difference.

() required only if you need to pass parameters to the constructor, otherwise you could skip it.

+3
source

Source: https://habr.com/ru/post/1529175/


All Articles