Re: __toString & friends

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jim Lucas wrote:
Leurent Francois wrote:
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.


concurred; I recently made a class that turn's all objects into XML; and implented it in my __toString()'s :)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux