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

From: Date: Tue, 12 Apr 2005 09:07:44 +0000
Subject: Why does PHP have __toString() and not just toString()
Groups: php.general 
Request: Send a blank email to php-general+get-212893@lists.php.net to get a copy of this message
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

« previous php.general (#212893) next »