From: mbneto at gmail dot com
Operating system: Linux
PHP version: 5.1.0b3
PHP Bug Type: Class/Object related
Bug description: using __toString with . causes the object id to be printed
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 bug report at http://bugs.php.net/?id=34079&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34079&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=34079&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=34079&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34079&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34079&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34079&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34079&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34079&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34079&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34079&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=34079&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=34079&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34079&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34079&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34079&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34079&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34079&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34079&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34079&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34079&r=mysqlcfg