note 69913 added to function.htmlentities
| From: | eric dot walletatyahoo dot fr at osu1 dot php dot net | Date: | Tue, 26 Sep 2006 11:57:23 +0000 |
| Subject: | note 69913 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117677@lists.php.net to get a copy of this message | ||
function htmlnumericentities($str){
return preg_replace('/[^!-%\x27-;=?-~ ]/e',
'"&#".ord("$0").chr(59)', $str);
}
function numericentitieshtml($str){
return utf8_encode(preg_replace('/&#(\d+);/e',
'chr(str_replace(";","",str_replace("&#","","$0")))',
$str));
}
echo (htmlnumericentities ("Ceci est un test : & é $ à ç <"));
echo ("<br/>\n");
echo (numericentitieshtml (htmlnumericentities ("Ceci est un test : & é $ à ç
<")));
Output is :
Ceci est un test : & é $ à ç <<br/>
Ceci est un test : & é $ à ç <
First method convert characters to decimal values.
Second will reverse the problem !!!
----
Server IP: 217.174.203.10
Probable Submitter: 194.2.70.197
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- https://master.php.net/note/edit/69913
Del: integrated -- https://master.php.net/note/delete/69913/integrated
Del: useless -- https://master.php.net/note/delete/69913/useless
Del: bad code -- https://master.php.net/note/delete/69913/bad+code
Del: spam -- https://master.php.net/note/delete/69913/spam
Del: non-english -- https://master.php.net/note/delete/69913/non-english
Del: in docs -- https://master.php.net/note/delete/69913/in+docs
Del: other reasons-- https://master.php.net/note/delete/69913
Reject -- https://master.php.net/note/reject/69913
Search -- https://master.php.net/manage/user-notes.php