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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ilia@php.net
New email:
PHP Version: OS:

 

 [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 04:01:31 2024 UTC