Re: Missing __toString() part
| From: | Derick Rethans | Date: | Sat, 03 Jun 2006 13:34:42 +0000 |
| Subject: | Re: Missing __toString() part | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-23884@lists.php.net to get a copy of this message | ||
On Sat, 3 Jun 2006, Marcus Boerger wrote:
> Hello Robert,
>
> well lazy is a good point here but __toString is all about lazyness.
> Then again as said you might want to have objects naturally convert
> to strings whereever possible. Generally when providing a __toString
> implementation you say that you want this. And then you might as well
> expect that your objects can be used as index to arrays.
>
> The example is as said an object that can be used to calculate the
> index to an array. Assuming you deal with persons derived from
> a database as classes, your person objects might be implmeneted so
> that __toString simply returns the name of the persons. Now when your
> application also has an array that stores more information about the
> persons it would be nice if you could access that array direectly by
> your peson objects.
Makes sense to me, so +1.
Derick
--
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org