Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31325 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11073 invoked by uid 1010); 30 Jul 2007 18:35:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 11057 invoked from network); 30 Jul 2007 18:35:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jul 2007 18:35:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:55242] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6F/F2-18641-94F2EA64 for ; Mon, 30 Jul 2007 14:35:10 -0400 Received: from dhcp-172-30-11-223.zrh.corp.google.com (unknown [216.239.55.7]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id A7D6E1B3524; Mon, 30 Jul 2007 20:34:33 +0200 (CEST) Date: Mon, 30 Jul 2007 20:34:33 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1259100072.20070730203433@marcus-boerger.de> To: Pavel Shevaev CC: Marcus Boerger , Sebastian Bergmann , In-Reply-To: References: <468519DC.8060502@widescreen.ch> <4685785E.5010709@zend.com> <585221804.20070701154538@marcus-boerger.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] toString() and Object #ID From: helly@php.net (Marcus Boerger) 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