ID: 26962 Updated by: [EMAIL PROTECTED] Reported By: alex_mailbox53 at yahoo dot com -Status: Open +Status: Feedback Bug Type: Zend Engine 2 problem Operating System: Gentoo Linux PHP Version: 5.0.0b3 (beta3) New Comment:
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 Previous Comments: ------------------------------------------------------------------------ [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