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;
See Question&Answers more detail:os