这是代码&它的输出我用来画出如下推论:
class a { public $var1; public $var2; } $obj0 = new a; var_dump($obj0); class b { public $var1; public $var2; public $var3; } $obj1 = new b; var_dump($obj1); $obj2 = new stdClass; var_dump($obj2); $obj3 = new stdClass; var_dump($obj3); $obj4 = new stdClass; var_dump($obj4); $obj5 = new stdClass; var_dump($obj5); var_dump(new stdClass); $obj6 = new stdClass; var_dump($obj6);
输出:
object(a)#1 (2) { ["var1"]=> NULL ["var2"]=> NULL } object(b)#2 (3) { ["var1"]=> NULL ["var2"]=> NULL ["var3"]=> NULL } object(stdClass)#3 (0) { } object(stdClass)#4 (0) { } object(stdClass)#5 (0) { } object(stdClass)#6 (0) { } object(stdClass)#7 (0) { } object(stdClass)#7 (0) { }
#< some-number>在对象的var_dump中的行对象(someClass)旁边实际上是#< count> ;.哪里,
count is the number of objects@H_404_12@ / zval’s for objects@H_404_12@ irrespective of which class it belongs to that has been created till now. Which keeps getting incrementing for every object created & gets decremented by 1 when a refcount of a zval reaches zero i.e. Garbage Collection.
我对吗?
该数字是Z_OBJ_HANDLE_PP(struc),其中struc是一个zval,它导致Z_OBJVAL(zval).handle,它导致(zval).value.obj.
原文链接:https://www.f2er.com/php/139754.html参见http://php.net/manual/en/internals2.variables.intro.php
总之我会说这是object identifier用十进制格式写的(ref):
PHP_printf("%sobject(%s)#%d (%d) {\n",COMMON,class_name,Z_OBJ_HANDLE_PP(struc),myht ? zend_hash_num_elements(myht) : 0);
而不是创建的对象的数量.