Hello Pavel,

  I still fail to understand why spl_object_hash() does not work for you.
How about:

function foo($obj) {
  if (is_object($obj)) {
    return "object(" . get_class($obj) . ")#" . spl_object_hash($obj);
  }
  return NULL;
}

marcus

Sunday, July 1, 2007, 9:18:19 PM, you wrote:

>> Again see mail archive for why. That said the name appears to be
>> the best option already.

> Oh, yes, you're right spl_object_hash does its job and does it very
> well, there's really no point rename it(or make an alias) into
> object_get_id. I should have stated more clear what I think
> object_get_id could actually be.

> How about object_get_id being a function returning the very first line
> of var_dump's output being applied to the object? Let me be a bit more
> specific, here's an example of var_dump usage:

> $ php -r "class Foo{};$foo = new Foo();var_dump($foo);"
> object(Foo)#1 (0) {
> }

> What I actually need, not the object hash but simply its unique id.
> And in this case "object(Foo)#1" would be just fine. How can I get it?
> The only way AFAIK is to surround var_dump with
> ob_start/ob_get_contents/ob_end_clean functions and extract this
> value.

> The problem with approach is if one has a complex object connected
> with a graph of other complex objects(with recursive links) var_dump
> may take a _very_ long time to complete.
> And this is what object_get_id could do - simply return object id
> prefixed with the class name.




Best regards,
 Marcus

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to