__toString extension proposal
| From: | Marian Kostadinov | Date: | Tue, 19 Dec 2006 08:22:05 +0000 |
| Subject: | __toString extension proposal | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-27084@lists.php.net to get a copy of this message | ||
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;