On Mon, Dec 15, 2003 at 08:09:12AM +0200, Andi Gutmans 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"; > > Nope. How is it different or nicer than doing > $defect->thrownException()->__toString()? > It saves you 4 characters?
It's a contrived example. Perhaps it would make more sense if I phrased it like this: function printException($e) { print (string)$e; } ... where $e could be a string or an object. The alternative is to be explicit: function printException($e) { if (is_object($e) && method_exists($e, '__toString')) { print $e->__toString(); } else { print $e; } } I don't belong to the "character saving" camp. I'm really after expressive code that hides away administrative machinery whenever possible. -- Jon Parise ([EMAIL PROTECTED]) :: The PHP Project (http://www.php.net/) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php