0

I'm learning the advance concepts of php. What does new stdClass do? I know what new stdClass(); does.

For eg) <?php new stdClass(); ? > creates a new object. Does <?php new stdClass; ? > do the same thing? Notice there's no parentheses. Does that make a difference? I can't find documentation on it for php manual.

phuclv
  • 37,963
  • 15
  • 156
  • 475

1 Answers1

5

There is no difference. PHP lets you omit the parentheses if you're not passing arguments to the constructor.

DisgruntledGoat
  • 70,219
  • 68
  • 205
  • 290
Nate Higgins
  • 2,104
  • 16
  • 21
  • `$a=new stdClass();var_dump($a);` shows `object(stdClass)#1 (0) { }` while `$a= new stdClass;var_dump($a);` shows `object(stdClass)#2 (0) { }`. Why is the difference ? – Istiaque Ahmed Sep 12 '17 at 13:23