ID: 26962 Updated by: [EMAIL PROTECTED] Reported By: alex_mailbox53 at yahoo dot com -Status: No Feedback +Status: Bogus Bug Type: Zend Engine 2 problem Operating System: Gentoo Linux PHP Version: 5.0.0b3 (beta3) 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 For 5.0.x this is expected behavior. __toString() will only called automatically for echo and print constructs. Maybe we'll change that for 5.1. Previous Comments: ------------------------------------------------------------------------ [2004-07-28 22:40:13] Maik_Heller at hotmail dot com problem still exists even with lates build (for win) ------------------------------------------------------------------------ [2004-01-24 23:59:56] [EMAIL PROTECTED] No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. ------------------------------------------------------------------------ [2004-01-19 13:07:05] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2004-01-19 05:01:43] alex_mailbox53 at yahoo dot com Description: ------------ The ZEND_CHANGES defines that __toString method whould be called whenever object is casted to sting. But actually it is casted to string only during print (echo) operator. Even the example in ZEND_CHANGES does not work: class Foo { function __toString() { return "What ever"; } $obj = Foo; $str = (string) $obj; // call __toString() echo $obj; // call __toString() print $str will print the "Object" sring, not the "What ever". One more code example: class Integer { private $value; function __construct($val) { $this->value = $val; } function __toString() { return (string)($this->value); } } $i = new Integer(10); if (10 == $i) echo '10!!!! :-)'; "10!!! :-)" is not printed. Expected result: ---------------- When object is accessed in expressions it should be explicitly casted to sting nor vartype. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26962&edit=1