#32696 [Opn->Bgs]: (stirng)cast breaks __toString() for exceptions

From: Date: Wed, 13 Apr 2005 14:50:57 +0000
Subject: #32696 [Opn->Bgs]: (stirng)cast breaks __toString() for exceptions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-77466@lists.php.net to get a copy of this message
ID: 32696 Updated by: iliaa@php.net Reported By: ilia@php.net -Status: Open +Status: Bogus Bug Type: Zend Engine 2 problem Operating System: ANY PHP Version: 5CVS-2005-04-13 (dev) New Comment: not a bug, although a rather unusual situation. Previous Comments: ------------------------------------------------------------------------ [2005-04-13 16:29:00] ilia@php.net Description: ------------ Adding (string) cast to an exception object on output causes PHP to output the object identifier rather then executing __toString() and printing the defined text. Removing the (string) cast on output makes the desired behaviour occur (print "Test 123"). Reproduce code: --------------- <?php class E extends Exception { public function __toString() { return "Test 123"; } } try { throw new E(); } catch (E $e) { echo (string) $e; } ?> Expected result: ---------------- Test 123 Actual result: -------------- Object id #1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32696&edit=1

« previous php.bugs (#77466) next »