#32696 [NEW]: (stirng)cast breaks __toString() for exceptions
| From: | ilia@php.net | Date: | Wed, 13 Apr 2005 14:29:01 +0000 |
| Subject: | #32696 [NEW]: (stirng)cast breaks __toString() for exceptions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-77464@lists.php.net to get a copy of this message | ||
From: ilia@php.net
Operating system: ANY
PHP version: 5CVS-2005-04-13 (dev)
PHP Bug Type: Zend Engine 2 problem
Bug description: (stirng)cast breaks __toString() for exceptions
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 bug report at http://bugs.php.net/?id=32696&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32696&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32696&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32696&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32696&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32696&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32696&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32696&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32696&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32696&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32696&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=32696&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=32696&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32696&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32696&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32696&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32696&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32696&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32696&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32696&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32696&r=mysqlcfg