php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: scm2tj at cs dot cf dot ac dot uk
New email:
PHP Version: OS:

 

 [2004-07-21 12:58 UTC] scm2tj at cs dot cf dot ac dot uk
Description:
------------
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:
---------------
<?php
class Foobar {
    public function __toString() {
        return "Foo";
    }
}
$bar = new Foobar;
die($bar);
?>

Expected result:
----------------
Foo

Actual result:
--------------
Object id #1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

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: Tue Apr 23 06:01:30 2024 UTC