|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #29295 die() does not call $obj->__toString()
Submitted: 2004-07-21 12:58 UTC Modified: 2004-07-21 20:11 UTC
From: scm2tj at cs dot cf dot ac dot uk Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.0.0 OS:
Private report: No CVE-ID: None
 [2004-07-21 12:58 UTC] scm2tj at cs dot cf dot ac dot uk
Using the die() function and passing a object as a parameter, you'd expect the __toString() function to be called, but it isn't. I understand there are problems with concatenation, but in this instance, just the object is being passed.

Reproduce code:
class Foobar {
    public function __toString() {
        return "Foo";
$bar = new Foobar;

Expected result:

Actual result:
Object id #1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-21 20:11 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

In 5.0.x __toString() will only be called automatically for print/echo. Maybe we will change that for 5.1.x if we find out how.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 21:01:28 2024 UTC