Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between object creation using `new ClassName` and `new ClassName()` in PHP

Tags:

syntax

php

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?

like image 716
Kamran Ahmed Avatar asked Dec 25 '22 12:12

Kamran Ahmed


1 Answers

Nope, no difference whatsoever. If you don't need to pass parameters to the constructor, the parentheses are entirely superfluous.

like image 139
deceze Avatar answered Dec 30 '22 09:12

deceze