note 96684 added to function.htmlentities
| From: | sushantverma at osu1 dot php dot net | Date: | Thu, 11 Mar 2010 13:52:21 +0000 |
| Subject: | note 96684 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-166912@lists.php.net to get a copy of this message | ||
i m trying to parse the html tags namely < > " ' and & into
< > " ' and &
i m writing the following code and tried with some other codes also which are commented here,
but what i got is:
<?php
function parse($code)
{
echo htmlspecialchars($code, ENT_COMPAT);
echo "<br />";
//output: < > & \" \'
echo htmlentities($code, ENT_QUOTES);
echo "<br />";
//output: < > & \" \'
$text = str_replace( array('>', '<', '\"',
"\'"), array('>', '<', '"',
'''),$code);
echo str_replace('&','&',$text);
//output: < > & " '
echo "<br />";
$arr=array('>'=>'>', '<'=>'<',
'\"'=>'"',
'&'=>'&','\''=>''');
echo strtr( $code,$arr);
//output: < > & " \'
}
$tag=$_POST['html_parse'];
echo parse($tag);
?>
plz help me to print "&" on the browser for every '&"
the sourse code of the browser says:
<html>
<body>
<
>
&
\"
\'<br /><
>
&
\"
\'<br />&lt;
&gt;
&
&quot;
&#039;<br /><
>
&
"
\'
</body>
</html>
plz help me out
----
Server IP: 69.147.83.197
Probable Submitter: 121.242.88.23
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- https://master.php.net/note/edit/96684
Del: integrated -- https://master.php.net/note/delete/96684/integrated
Del: useless -- https://master.php.net/note/delete/96684/useless
Del: bad code -- https://master.php.net/note/delete/96684/bad+code
Del: spam -- https://master.php.net/note/delete/96684/spam
Del: non-english -- https://master.php.net/note/delete/96684/non-english
Del: in docs -- https://master.php.net/note/delete/96684/in+docs
Del: other reasons-- https://master.php.net/note/delete/96684
Reject -- https://master.php.net/note/reject/96684
Search -- https://master.php.net/manage/user-notes.php