--TEST-- ZE2 __toString() --SKIPIF-- --FILE-- __toString()] = "ERROR"; echo $ar[$o]; echo "====test8====\n"; var_dump(trim($o)); var_dump(trim((string)$o)); echo "====test9====\n"; echo sprintf("%s", $o); ?> ====DONE!==== --EXPECTF-- ====test1==== test1 Object ( ) Notice: Object of class test1 could not be converted to string in %stostring.php on line %d string(12) "Object id #%d" object(test1)#%d (0) { } ====test2==== test2 Object ( ) test2::__toString() Converted object(test2)#%d (0) { } ====test3==== test2::__toString() Converted ====test4==== test2::__toString() string:Converted ====test5==== test2::__toString() 1Converted ====test6==== test2::__toString() test2::__toString() Converted Converted ====test7==== test2::__toString() Warning: Illegal offset type in %stostring.php on line %d ====test8==== Notice: Object of class test2 could not be converted to string in %stostring.php on line %d string(6) "Object" test2::__toString() string(9) "Converted" ====test9==== test2::__toString() Converted ====DONE!====