Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27086 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35895 invoked by uid 1010); 19 Dec 2006 09:10:44 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 35880 invoked from network); 19 Dec 2006 09:10:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Dec 2006 09:10:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=colder@php.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=colder@php.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain php.net from 213.239.212.54 cause and error) X-PHP-List-Original-Sender: colder@php.net X-Host-Fingerprint: 213.239.212.54 dns1.omne-serveurs.net Linux 2.4/2.6 Received: from [213.239.212.54] ([213.239.212.54:44116] helo=dns1.omne-serveurs.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 81/E0-28369-D4CA7854 for ; Tue, 19 Dec 2006 04:10:08 -0500 Received: (qmail 22457 invoked from network); 19 Dec 2006 09:09:30 -0000 Received: from 84.74.74.132 by dns1 (envelope-from , uid 1004) with qmail-scanner-1.23 (clamdscan: 0.82. spamassassin: 3.0.1. perlscan: 1.32. Clear:RC:1(84.74.74.132):. Processed in 0.027748 secs); 19 Dec 2006 09:09:30 -0000 Received: from 84-74-74-132.dclient.hispeed.ch (HELO ?10.0.0.1?) (84.74.74.132) by dns1.omne-serveurs.net with (DHE-RSA-AES256-SHA encrypted) SMTP; 19 Dec 2006 09:09:29 -0000 Message-ID: <4587AC4C.7090308@php.net> Date: Tue, 19 Dec 2006 10:09:32 +0100 User-Agent: Thunderbird 1.5.0.7 (X11/20060909) MIME-Version: 1.0 To: Marian Kostadinov CC: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] __toString extension proposal From: colder@php.net (Etienne Kneuss) Hi, you can use: class test2 { public function __toString(){ return (string) new test; } } Marian Kostadinov wrote: > Hi, > there is one issue that I experience since I started using 5.2.0 and > especially the new correct __toString behaviour. Generally it works fine. > But sometimes I find it useful to get __toString return another object > the > also has a __toString method. So my idea is - is it possible (and good > idea) > to make it work in this extended manner. Here is an example to illustrate > what I mean: > > class test1 { > function __toString() { return 'i am class 1'; } > } > class test2 { > function __toString() { return new test1; } > } > $test = new test2; > echo $test; > -- Etienne Kneuss http://www.colder.ch colder@php.net Men never do evil so completely and cheerfully as when they do it from a religious conviction. -- Pascal