0

Possible Duplicate:
Get Instance ID of an Object in PHP

I'm new to OOP and I have an object. If I:

var_dump($obj);

I get:

object(stdClass)[55]
    public 'date' => int 1295297161
    public 'id' => int 11

How can I retrieve the "55"?

Community
  • 1
  • 1
MT3
  • 1,065
  • 3
  • 13
  • 22
  • 4
    For what do you need that 'index'? It's not an array key, it's more like internal identifier. – Radek Benkel Feb 11 '11 at 09:34
  • 1
    The only way to get that 55 value is to "parse" the output from the var_dump()... but there is no valid reason why you should need this information. Any reason you might have can probably better be implemented using different methods (e.g. an array of objects) – Mark Baker Feb 11 '11 at 09:46
  • Related: [Get Instance ID of an Object in PHP](http://stackoverflow.com/questions/2872366/get-instance-id-of-an-object-in-php) – BoltClock Feb 11 '11 at 09:53

1 Answers1

1

As others have mentioned you can't read it, without parsing the output of var_dump. But if all you are looking for is a way to uniquely identify an object, then you should use spl_object_hash.

NikiC
  • 100,734
  • 37
  • 191
  • 225