stdClass Object¶
<?php
var_dump(new stdclass);
var_dump((object) []);
var_dump($b = new stdclass());
var_dump(new stdclass(3));
PHP recycles the previously created stdClass objects ids. The following code displays Object #1, until it is stored in $b. When the stdClass is not stored in a container (variable, property, etc.), it is completely lost and no object counting happens.
Also, PHP’s stdClass’s constructor ignores all its arguments, as they are not used.
See Also¶
PHP Features¶
Last updated: 14 July 2026