下面是过滤HTML代码的函数:
复制代码代码如下所示:
功能ihtmlspecialchars($string){
如果(is_array($字符串)){
foreach($字符串作为键=美元美元Val){
为字符串{ $关键} = ihtmlspecialchars(美元值);
}
{人}
($字符串preg_replace /((#( D {二} | x { a-fa-f0-9 } { 4 }){ } { } | a-za-z a-z0-9 {2,5 }); / 1),
str_replace(array(' ',' ',' '),阵列(' ',' ',' '),为字符串);
}
返回$字符串;
}


PHP下过滤HTML代码的功能
复制代码代码如下所示:
功能HtmlEncode($string){
美元=修剪($字符串);
$字符串str_replace(
$字符串str_replace(,
$字符串str_replace(
$字符串str_replace(
$字符串str_replace(
$字符串str_replace(<
$字符串str_replace(<
$字符串str_replace(> > ,
$字符串str_replace(> > ,
$字符串str_replace(
字符串(字符串nl2br美元美元);
返回$字符串;
}