|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-11-28 23:55 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 03:00:01 2025 UTC |
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.