php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32696 (stirng)cast breaks __toString() for exceptions
Submitted: 2005-04-13 16:29 UTC Modified: 2005-04-13 16:50 UTC
From: ilia@php.net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2005-04-13 (dev) OS: ANY
Private report: No CVE-ID: None
 [2005-04-13 16:29 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-13 16:50 UTC] iliaa@php.net
not a bug, although a rather unusual situation.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 06:01:31 2024 UTC