Re: __toString()
| From: | Sebastian Bergmann | Date: | Mon, 15 Dec 2003 06:08:18 +0000 |
| Subject: | Re: __toString() | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-6455@lists.php.net to get a copy of this message | ||
Jon Parise wrote:
> Hopefully, this still works (don't have a recent PHP5 build to try):
>
> print (string)$defect->thrownException();
>
> The explicit cast also addresses this case:
>
> print (string)$defect->thrownException() . "\n";
<?php
class Foo {
private $bar = 'foobar';
public function __toString() {
return $this->bar;
}
}
$foo = new Foo;
print $foo;
?>
prints
Object id #1
--
Sebastian Bergmann
http://sebastian-bergmann.de/ http://phpOpenTracker.de/
Das Buch zu PHP 5: http://professionelle-softwareentwicklung-mit-php5.de/