This question already has an answer here:
For example, in the manual
<?php
class C {}
function getC(): C {
return new C;
}
var_dump(getC());
?>
Output
object(C)#1 (0) {
}
What does #1
, (0)
mean?
</div>
The #X
is the order of instantiation of the object and the (X)
is the number of properties:
class C {
public $a;
}
$a = new C;
$b = new C;
var_dump($b); // instantiated second
var_dump($a); // instantiated first
Yields #1
for the first instantiated object and #2
for the second and (1)
for both since they have one property a
:
object(C)#2 (1) {
["a"]=>
NULL
}
object(C)#1 (1) {
["a"]=>
NULL
}
#1
is a unique identifier for each object, to allow you to tell when the same object appears in multiple places in the output.
(0)
is the number of properties of the object. Since C
has no properties, it's zero in this case.