Re: __toString extension proposal

From: Date: Tue, 19 Dec 2006 09:09:32 +0000
Subject: Re: __toString extension proposal
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-27086@lists.php.net to get a copy of this message
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

« previous php.internals (#27086) next »