|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-01-19 13:07 UTC] helly@php.net
[2004-01-24 23:59 UTC] sniper@php.net
[2004-07-28 22:40 UTC] Maik_Heller at hotmail dot com
[2004-07-28 23:01 UTC] helly@php.net
[2004-07-28 23:24 UTC] helly@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 04:00:01 2025 UTC |
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.