ID:               37597
 User updated by:  doublecompile at gmail dot com
 Reported By:      doublecompile at gmail dot com
-Status:           Bogus
+Status:           Open
 Bug Type:         Strings related
 Operating System: *
 PHP Version:      5.2.*
 Assigned To:      helly
 New Comment:

Try this on for size:

<?php

class test {
        public $value;
}

$test = new test();
$test->value = "1234";

$test2 = new test();
$test->value = "5678";

$test3 = new test();
$test->value = "7890";

$example = array( $test, $test2, $test3, $test3 );

$filtered = array_unique( $example );

?>

Outputs:

Catchable fatal error: Object of class test could not be converted to
string in ...


Previous Comments:
------------------------------------------------------------------------

[2006-05-26 01:56:29] [EMAIL PROTECTED]

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

The object id is not useable in any way.

------------------------------------------------------------------------

[2006-05-26 01:49:53] doublecompile at gmail dot com

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 this bug report at http://bugs.php.net/?id=37597&edit=1

Reply via email to