From: php at koteroff dot ru
Operating system: Windows
PHP version: 5.0.0RC2
PHP Bug Type: Zend Engine 2 problem
Bug description: __toString() does not work in echo "x=$x"
Description:
------------
Method __toString() work in PHP5 RC1 correctly, but in PHP4 RC2 - wrong
(in today CVS - too). Bewitched method? :-) There are so many bugs and
changes around them in all PHP versions... I'm finishing the book about
PHP5, please say if __toString() behavour will be changed in release.
P.S.
I cannot understand too why this method is called only in print and echo
functions - thanks to it I cannot write
function myecho($s) { echo $s; }
myecho("x=$x");
But, I think, it is another question.
Reproduce code:
---------------
<?
class C {
function __toString() { return "s"; }
}
$x = new C;
echo "x=$x";
?>
Expected result:
----------------
x=s
Actual result:
--------------
x=Object id #1
(and NO warning or notice)
--
Edit bug report at http://bugs.php.net/?id=28292&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28292&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28292&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28292&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28292&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28292&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28292&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28292&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28292&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28292&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28292&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28292&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28292&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28292&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28292&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28292&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28292&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28292&r=float