ID: 41221 Comment by: judas dot iscariote at gmail dot com Reported By: oliver dot graetz at gmx dot de Status: Open Bug Type: Documentation problem Operating System: Windows XP PHP Version: Irrelevant New Comment:
Your rationale is plain wrong, the old behaviuor is really broken, outputting "Object" does not make any sense and is not helpful at all..(what the hell you will do with it? and no, as a debugging output is useless too, in that case use var_dump() to see the contents of the object) About the DateTime() object, it does not implement __toString hence the message is correct, if you need such functionaly you can always extend the base object to add an string representation. What is really not expected is objects behaving like strings in contexts you dont specifically want that. Previous Comments: ------------------------------------------------------------------------ [2007-04-29 04:52:19] oliver dot graetz at gmx dot de Description: ------------ In the documentation under http://php.net/manual/en/language.types.string.php#language.types.string.casting it reads "Objects are always converted to the string "Object"." This is not true: php -r "echo PHP_VERSION;echo new StdClass;" 5.2.2RC3-dev Catchable fatal error: Object of class stdClass could not be converted to string in Command line code on line 1 The documentation should be changed to: "Objects are not converted to anything unless you define a __toString() method. If you can't because you are using an engine internal class then you are busted. This is especially annoying with functions like implode() that stop working when their arguments contain such objects. Sorry for this inconvenience but we refuse to listen to any bug report about this and blindly change any complaint to BOGUS." Of course the real fix would be providing the documented "Object" as fallback instead of raising a recoverable error. But as my documentation suggestion states: You are not listening. In my opinion the current behaviour is a real showstopper. For further nagging read http://bugs.php.net/bug.php?id=40799 Reproduce code: --------------- echo new StdClass; Expected result: ---------------- Object Actual result: -------------- Catchable fatal error: Object of class stdClass could not be converted to string in Command line code on line 1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41221&edit=1