PHP/Class/toString
class toString
<source lang="html4strict">
<?php class Person {
function getName() { return "Joe"; } function getAge() { return 31; } function __toString() { $desc = $this->getName()." (age ". $desc .= $this->getAge().")"; return $desc; }
} $person = new Person(); print $person; ?>
</source>