From: brandon at osuosl dot org Operating system: Debian Unstable PHP version: 5.0.1 PHP Bug Type: Zend Engine 2 problem Bug description: Cannot use __toString on $this
Description: ------------ The automatic __toString method does not work on $this. I don't know if it should or not but it seems like it should be ok to do this. Thanks. http://dev2.osuosl.org/~philips/tostring/index.php http://dev2.osuosl.org/~philips/tostring/index.phps Reproduce code: --------------- class Foo { function __toString() { return "What ever"; } function ihatemylife() { $str = (string) $this; return $str; } } $obj = new Foo; $str = (string) $obj; // call __toString() echo $obj; // call __toString() echo "<br />"; echo $obj->ihatemylife(); echo "<br />"; phpinfo(); Expected result: ---------------- This line should return "What ever" echo $obj->ihatemylife(); Actual result: -------------- Object id #1 -- Edit bug report at http://bugs.php.net/?id=30098&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30098&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30098&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30098&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30098&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30098&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30098&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30098&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30098&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30098&r=support Expected behavior: http://bugs.php.net/fix.php?id=30098&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30098&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30098&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30098&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30098&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30098&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30098&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30098&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30098&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30098&r=mysqlcfg