Re: __toString()
| From: | Andi Gutmans | Date: | Mon, 15 Dec 2003 12:28:41 +0000 |
| Subject: | Re: __toString() | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-6465@lists.php.net to get a copy of this message | ||
Guys,
We have had this discussion before. There are two extremes to this issue. The first is to always require the explicit __toString() call and the second is to never require it and have all places in PHP whether it's str_replace(), (string)$obj, $arr[$obj] to automatically convert to string. The latter is problematic because it propagates to far too many places and causes too much magic in my opinion.
I think the right trade off is to automatically convert it with "print" and with concatenation. All the rest will require explicit calling.
It might not be your dream but it's a realistic approach.
Andi