NotionCommotion Posted January 14, 2017 Share Posted January 14, 2017 What does the #1 in object(stdClass)#1 (3) {} represent? <?php $a = (object) array('a'=>1, 'b'=>2, 'c'=>array("a", "b", "c")); var_dump($a); [Michael@devserver react]$ php var_dump.php object(stdClass)#1 (3) { ["a"]=> int(1) ["b"]=> int(2) ["c"]=> array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" } } [Michael@devserver react]$ Quote Link to comment Share on other sites More sharing options...
requinix Posted January 14, 2017 Share Posted January 14, 2017 It's a counter PHP manages for object instances - no two that exist at the same time will have the same number. Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted January 14, 2017 Author Share Posted January 14, 2017 It's a counter PHP manages for object instances - no two that exist at the same time will have the same number. Thanks. Why doesn't SplObjectStorage use it to identify objects (I believe it uses a hash of the object)? Other than to PHP, is this number useful? I guess it can be used when debugging to confirm one is looking at the same object. Is there any a time one would use this number in a script? Quote Link to comment Share on other sites More sharing options...
Solution requinix Posted January 14, 2017 Solution Share Posted January 14, 2017 Why doesn't SplObjectStorage use it to identify objects (I believe it uses a hash of the object)?That's right, and I don't know. It's quite possible - likely, even - that I don't know the full story behind what the number is and how it works. Other than to PHP, is this number useful?Only when debugging. I guess it can be used when debugging to confirm one is looking at the same object.Right. Is there any a time one would use this number in a script?Nope. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.