Reputation: 12428
I know, in PHP, we can create an object using new ClassName
and also using new ClassName()
(notice the parenthesis). Is there ANY difference between both of these ways at all?
Upvotes: 4
Views: 144
Reputation: 522005
Nope, no difference whatsoever. If you don't need to pass parameters to the constructor, the parentheses are entirely superfluous.
Upvotes: 7
Reputation: 160833
No, there is no difference.
The ()
is required only if you have to pass parameters to the constructor, otherwise it could be omitted.
Upvotes: 3