ID: 28292
User updated by: php at koteroff dot ru
Reported By: php at koteroff dot ru
Status: Bogus
Bug Type: Zend Engine 2 problem
Operating System: Windows
PHP Version: 5.0.0RC2
New Comment:
So, nowadays __toString() does not work at all and NOT planned to be
fixed in near half-year?
Previous Comments:
------------------------------------------------------------------------
[2004-05-06 06:20:52] [EMAIL PROTECTED]
This was changed due to potential bugginess in certain
cases. It will be readdressed in PHP 5.1.
------------------------------------------------------------------------
[2004-05-06 02:33:05] php at koteroff dot ru
Appositely,
echo "x=".((string)$x);
does not work too in PHP5 RC2!
------------------------------------------------------------------------
[2004-05-06 02:00:39] php at koteroff dot ru
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 this bug report at http://bugs.php.net/?id=28292&edit=1