Hi!
It seems like __toString() method is not called as it is announced on
http://www.php.net/zend-engine-2.php
The only working case is when you pass an object to echo().

Unfortunately, I couldn't check out the bugs DB, because there's no access
to bugs.php.net from my ISP. So, I'm awfully sorry if you're aware of this
issue already, and/or this all has been discussed before.

in plain English:

--TEST--
PHP5 __toString() method
--FILE--
<?php

class A {
  function __toString() { return "ABC"; }
}

$a = new A();
$b = (string)$a;

echo $a; echo "\n";
echo "".$a."\n";
echo $b."\n";
?>
--EXPECT--
ABC
ABC
ABC

the test outputs:
ABC
Object id #1
Object id #1

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to