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 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

Pull Requests

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: Sun Dec 22 02:01:28 2024 UTC