Is there a difference between instantiation with parentheses or without?
问题 What's the difference between these 2 piece of codes? <?php $object1 = new User(); //^^ $object1->name = "Hello"; echo $object1->name; class User {} ?> And: <?php $object1 = new User; //^ $object1->name = "Hello"; echo $object1->name; class User {} ?> I get the same output: Hello So is there any difference if I use the parentheses or not in: $object1=new User; 回答1: The are exactly the same, you can compare opcode of these 2 scripts: 1 script: $object1=new User(); $object1->name="Hello"; echo