From: doublecompile at gmail dot com
Operating system: Ubuntu Linux 5.04
PHP version: 5CVS-2006-05-26 (snap)
PHP Bug Type: Strings related
Bug description: Cannot stringify objects without __toString
Description:
------------
Attempting to stringify (casting, strval, echo) an instantiated class
without a __toString() method results in the following error:
Catchable fatal error: Object of class test could not be converted to
string in...
Built using php5.2-200605252230 Snap with the following config statement:
'./configure' '--with-mysql=/usr/local/php5/ext/mysql' '--with-pdo'
'--with-pdo-mysql' '--with-apxs2=/usr/bin/apxs2' '--with-zlib'
'--enable-bcmath' '--enable-calendar' '--with-gd=/usr'
'--with-jpeg-dir=/usr/include' '--with-zlib-dir=/usr/include'
'--with-png-dir=/usr/include' '--with-xpm-dir=/usr/include'
'--with-freetype-dir=/usr/include' '--with-ldap' '--with-mcrypt'
'--with-mhash' '--with-bz2' '--with-curl' '--enable-ftp' '--with-openssl'
'--with-mysqli' '--enable-exif' '--enable-wddx' '--with-xsl'
'--enable-sockets' '--enable-soap' '--with-pgsql=/usr/lib/postgresql'
'--with-pdo-pgsql=/usr/lib/postgresql' '--with-sqlite' '--with-pdo-sqlite'
'--with-ibm-db2=/home/db2inst1/sqllib'
'--with-pdo-odbc=ibm-db2,/home/db2inst1/sqllib' '--enable-mbstring'
'--with-gettext'
Reproduce code:
---------------
class test { }
$test = new test();
// any of the following would produce the error
$value = (string)$test;
$value = strval($test);
echo $test;
Expected result:
----------------
$value to be set to "Object #1"
or the echo to output "Object #1"
Actual result:
--------------
Catchable fatal error: Object of class test could not be converted to
string in...
--
Edit bug report at http://bugs.php.net/?id=37597&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=37597&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=37597&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=37597&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37597&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=37597&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37597&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37597&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37597&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37597&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37597&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=37597&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=37597&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37597&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37597&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37597&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37597&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37597&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37597&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37597&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37597&r=mysqlcfg