note 65597 deleted from function.html-entity-decode by bjori
| From: | bjori@php.net | Date: | Thu, 04 May 2006 11:10:40 +0000 |
| Subject: | note 65597 deleted from function.html-entity-decode by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-110511@lists.php.net to get a copy of this message | ||
Note Submitter: jdephix_at_hotmail_dot_com
----
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?