Re: __toString & friends
| From: | Nathan Rixham | Date: | Tue, 16 Sep 2008 17:29:42 +0000 |
| Subject: | Re: __toString & friends | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-280295@lists.php.net to get a copy of this message | ||
Jim Lucas wrote:
Leurent Francois wrote:concurred; I recently made a class that turn's all objects into XML; and implented it in my __toString()'s :)I was asking myself if there was a good reason __toBool // __toInt NOT been present in my favorite language, It is sooooo coool beeing able to cast object as string resulting in a __toString() call I'll really love being able to class error extends exeption { __toBool(){return false; } } .... if((bool) $result ) echo "This is ok"; .. 131 - praying for a automatic method called at casting request.I felt this would be a nice feature to have also. So, I added methods to my classes that would allow for this ability.