class dome{
}
$w =new dome();
$w1 =new $w();
echo get_class($w1);
Create a new class whose name is dome and then generate an object of $w. At this time, I use $w1 =new $w(); to create a new object instead of assigning a value. This is how I understand it. , which is equivalent to treating $w as a class, so a new object is generated, but using echo get_class($w1); the output is still dome, not $w. What is the principle? Because $w is not a class, its class is taken.
ringa_lee2017-08-07 11:04:12
There is something wrong with the code. $w has already generated an object. If you try $w1 and then new it, it won’t work. You can try $w1 = clone $w