#34079 [Opn->Bgs]: using __toString with . causes the object id to be printed
| From: | derick@php.net | Date: | Thu, 11 Aug 2005 06:48:38 +0000 |
| Subject: | #34079 [Opn->Bgs]: using __toString with . causes the object id to be printed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-83351@lists.php.net to get a copy of this message | ||
ID: 34079
Updated by: derick@php.net
Reported By: mbneto at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Linux
PHP Version: 5.1.0b3
New Comment:
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
.
Previous Comments:
------------------------------------------------------------------------
[2005-08-11 04:50:01] mbneto at gmail dot com
Description:
------------
When using a echo/print with an object that has a __toString method
defined it behaves strange depending on the usage.
echo $obj is fine
echo $obj."\n" is not
Reproduce code:
---------------
class TestClass
{
public $foo;
public function __construct($foo) {
$this->foo = $foo;
}
public function __toString() {
return $this->foo;
}
}
$n = new TestClass("test") ;
echo $n ; // works - shows test
echo $n."\n" ; // does not - show Object id #1
Expected result:
----------------
Test
Actual result:
--------------
Object id #1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34079&edit=1