note 93044 deleted from language.exceptions.extending by mazzanet
| From: | mazzanet@php.net | Date: | Thu, 20 Aug 2009 14:30:55 +0000 |
| Subject: | note 93044 deleted from language.exceptions.extending by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159705@lists.php.net to get a copy of this message | ||
Note Submitter: ashley at ls12style dot co dot uk
----
In response to paragdiwan at gmail dot com and their example.
You do not need to echo $e->__toString(); You simply need to echo
$e as the __toString method tells php what to do when the object is echo'ed.
for example:
<?php
class a
{
public $b;
public function __construct ($string)
{
$this->b = $string;
}
public function __toString ()
{
return $this->b;
}
}
$a = new a('hello');
echo $a;
//outputs "hello"
?>