Ask a Question related to PHP Development, Design and Development.
-
adam at trachtenberg dot com #1
#26265 [NEW]: zend_parse_parameters() doesn't coerce overloaded objects into strings
From: adam at trachtenberg dot com
Operating system: *
PHP version: 5CVS-2003-11-15 (dev)
PHP Bug Type: Zend Engine 2 problem
Bug description: zend_parse_parameters() doesn't coerce overloaded objects into strings
Description:
------------
When passing an object with a __toString() method to a
function that uses zend_parse_parameters() with an "s"
value, PHP does not correctly coerce the object into a
string.
This occurs for both extensions (like SimpleXML) and
user-defined PHP classes.
Reproduce code:
---------------
class foo {
function __toString() {
return "foo";
}
}
$foo = new foo;
print strrev($foo) ."\n";
print htmlspecialchars($foo) ."\n";
Alternatively:
$xml = '<?xml version="1.0" ?><root><element>text</element></root>';
$s = simplexml_load_string($xml);
print strrev($s->element) ."\n";
print htmlspecialchars($s->element) ."\n";
Expected result:
----------------
oof
foo
Actual result:
--------------
PHP Warning: htmlspecialchars() expects parameter 1 to
be string, object given in foo.php on line 10
oof
strrev() uses convert_to_string_ex(), so it works fine.
htmlspecialchars() uses zend_parse_parms(), so there's a
warning.
--
Edit bug report at [url]http://bugs.php.net/?id=26265&edit=1[/url]
--
Try a CVS snapshot (php4): [url]http://bugs.php.net/fix.php?id=26265&r=trysnapshot4[/url]
Try a CVS snapshot (php5): [url]http://bugs.php.net/fix.php?id=26265&r=trysnapshot5[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=26265&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=26265&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=26265&r=needtrace[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=26265&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=26265&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=26265&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=26265&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=26265&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=26265&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=26265&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=26265&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=26265&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=26265&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=26265&r=float[/url]
adam at trachtenberg dot com Guest
-
How to make PDF Printer use Hexadecimal strings in stream objects?
Happy new year everyone, I would like to be able to configure the PDF Printer functionality in Acrobat 7.0 to use hexadecimal strings when... -
ByteArray objects cannot be converted to strings??
I am using dreamweaverMX and ColdfusionMX to create a site that will display photos along with text info describing the photo. I have an Access DB... -
ByteArray objects cannot be converted to strings
We're migrating our application server from ColdFusion 5.1 to CF MX 7, and running into an issue with a specific web page. Our news stories are... -
#26266 [Com]: Concatenating overloaded objects causes crash
ID: 26266 Comment by: php at bouchery dot com Reported By: adam at trachtenberg dot com Status: Open Bug Type:... -
#25122 [NEW]: Control over typecasting objects to strings
From: a at b dot c dot de Operating system: Any PHP version: 5.0.0b1 (beta1) PHP Bug Type: Feature/Change Request Bug...



Reply With Quote

