note 65597 added to function.html-entity-decode
| From: | jdephix_at_hotmail_dot_com at osu1 dot php dot net | Date: | Thu, 04 May 2006 10:31:00 +0000 |
| Subject: | note 65597 added to function.html-entity-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-110508@lists.php.net to get a copy of this message | ||
I had a very strange problem with html_entity_decode on a string which begins with < followed
with a letter.
<?php
$str = "<option value='test'";
$s = htmlentities($str);
$var = html_entity_decode($str, ENT_QUOTES);
print $var; //nothing appears on screen (that's what it seems anyway)
print strlen($var);//20, the actual string length!
?>
So does it mean html_entity_decode returns a blank 20-character long string?
Nope.
<?php
$str2 = "Test <option value='test'>Test value";
print strpos($str2, $str);//returns 5!!
?>
If you tried the same thing with a string which begins with < followed with an integer
("<1test value='test'" for instance), the string is printed on screen. This
is because no XML tags start with an integer.
So what is happening when you pass a non-closed XML tag is that a string is returned, it is what one
would expect (as the strpos test shows) but it is simply NOT printed!
Now, bug or undocumented behaviour?
----
Server IP: 217.174.203.10
Probable Submitter: 195.68.46.222
----
X-Spam-Status: No, hits=4.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_30_40,HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.html-entity-decode.php
Edit -- http://master.php.net/note/edit/65597
Del: integrated -- http://master.php.net/note/delete/65597/integrated
Del: useless -- http://master.php.net/note/delete/65597/useless
Del: bad code -- http://master.php.net/note/delete/65597/bad+code
Del: spam -- http://master.php.net/note/delete/65597/spam
Del: non-english -- http://master.php.net/note/delete/65597/non-english
Del: in docs -- http://master.php.net/note/delete/65597/in+docs
Del: other reasons-- http://master.php.net/note/delete/65597
Reject -- http://master.php.net/note/reject/65597
Search -- http://master.php.net/manage/user-notes.php