#41549 [Bgs]: Object to String convert

From: Date: Fri, 01 Jun 2007 08:33:42 +0000
Subject: #41549 [Bgs]: Object to String convert
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-113255@lists.php.net to get a copy of this message
ID: 41549 User updated by: nikolai dot essel at maxworx dot com Reported By: nikolai dot essel at maxworx dot com Status: Bogus Bug Type: Class/Object related Operating System: Windows XP SP2 PHP Version: 5.2.2 New Comment: The manual http://de3.php.net/manual/en/language.types.string.php says [Quote] Objects are always converted to the string "Object". [Quote] Previous Comments: ------------------------------------------------------------------------ [2007-05-31 13:07:41] johannes@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php . ------------------------------------------------------------------------ [2007-05-31 13:02:07] nikolai dot essel at maxworx dot com Description: ------------ After updating from PHP 5.1.6 some scripts didn´t work. Problem is the standard behavior from casting objects into strings without an explicit defined __toString() method Reproduce code: --------------- <?php class test { private $var = "test"; public function __construct() {} } $object = new test(); echo $object; ?> Expected result: ---------------- Object id #1 Actual result: -------------- Catchable fatal error: Object of class test could not be converted to string in C:\xampp\htdocs\classtest.php on line 9 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41549&edit=1

« previous php.bugs (#113255) next »