How to escape characters in PHP? thank you !!! Urgent !!! The following new_content is the content returned by the select statement in mysql $ new_content & lt; P & gt; next I will introduce javascript functions: & lt; P & gt; & lt; PRE & nbsp; code & gt; & lt; script & gt; & nbsp; & lt; how to escape in br php. please help !!! Urgent !!!
The following new_content is returned by using select in mysql.
$ New_content ='The following describes javascript functions:
Script
Function show ()
{
Alert ("hello world ");
}
Script
Result
';
How can I convert "script" and "script" into <script> and </script>
------ Solution --------------------
Htmlspecialchars can be escaped.
------ Solution --------------------
$ New_content ='The following describes javascript functions:
Script
Function show ()
{
Alert ("hello world ");
}
Script
Result
';
Var_dump (preg_replace_callback ('/<\/? Script>/I ', function ($ r) {return htmlentities ($ r [0]) ;}, $ new_content ));