What is exactly happening when instantiating with 'new'?
问题 Let's consider the following code: class a { public $var1; function disp(){ echo $this->var1; } } $obj1 = new a; echo '<br/>After instantiation into $obj1:<br/>'; xdebug_debug_zval('obj1'); $obj1->var1 = "Hello "; echo '<br/><br/>After assigning "Hello" to $obj->var1:<br/>'; $obj1->disp(); echo "<br/><br/>"; xdebug_debug_zval('obj1'); The output: After instantiation into $obj1: obj1: (refcount=1, is_ref=0)=class a { public $var1 = (refcount=2, is_ref=0)=NULL } After assigning "Hello" to $obj-