Why does PHP have __toString() and not just toString()

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

 



Hello,


I'm a University student studying Java, but I also do some freelance web design - so naturally I do a fair bit of PHP which seems to be very similar to Java.


Usually I just code PHP as I need it, but down the track get REALLY annoyed when I need to edit or update my code. It's hard to follow and doesn't really have any order.

Then it came to me - why don't I code PHP with classes and plan my PHP like I do with Java. So today I looked into the PHP manual to find out about classes and objects in PHP.

I'm wondering, why does the toString() of classes have two underscored preceding it [e.g. __toString()], as opposed to Java's normal toString()?

What's the purpose of the two underscores in PHP's classes?

Thanks

Tim

--
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