From:             adam at trachtenberg dot com
Operating system: *
PHP version:      5CVS-2004-02-03 (dev)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  strval() doesn't work for objects with __toString()

Description:
------------
When strval() is passed an object with a __toString() 
method, strval() should return the results of 
__toString().

This makes strval() consistent with (string), which the 
PHP manual agree to be the same thing:

"You can convert a value to a string using the (string) 
cast, or the strval() function."

See also internals list discussion: http://www.mail-
archive.com/[EMAIL PROTECTED]/msg05832.html

Reproduce code:
---------------
class foo {
        public function __toString() {
                return "foo\n";
        }
}

$foo = new foo;
print strval($foo);

Expected result:
----------------
foo

Actual result:
--------------
PHP Notice:  Object of class foo could not be converted 
to string in /Users/adam/Documents/php/php5/toString.php 
on line 10

-- 
Edit bug report at http://bugs.php.net/?id=27125&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27125&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27125&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27125&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27125&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27125&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27125&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27125&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27125&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27125&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27125&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27125&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27125&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27125&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27125&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27125&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27125&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27125&r=float

Reply via email to