You are here: Why does PHP have __toString() and not just toString() « PHP « IT news, forums, messages
Why does PHP have __toString() and not just toString()

Posted by Tim Burgan on 04/12/05 12:07

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация