1 回答

TA贡献1155条经验 获得超0个赞
程序里面下面这一句有语法错误:
$content=str_replace(chr(34),""",$content);
可以修改为:
$content=str_replace(chr(34),'"'",$content);
或者取消,好像没有什么本质意义。
程序前面几行替换HTML代码的,代码中间不能有空格,你写错了。
我修改后,完整的测试程序如下,测试通过,没有问题,能够替换:
<?php
function unhtml($content)
{
$content=str_replace("&","&",$content);
$content=str_replace("<","<",$content);
$content=str_replace(">",">",$content);
$content=str_replace(" "," ",$content);
$content=str_replace(chr(13),"<br>",$content);
$content=str_replace("\\","\\\\",$content);
$content=str_replace("台什么","不文明用语",$content);
$content=str_replace("[emt]","<img src=images/xyq/",$content);
$content=str_replace("[/emt]",".gif/>",$content);
return $content;
}
$str='台什么[emt]1[/emt]';
echo unhtml($str);
?>
程序运行过程如下:
E:\ygb>php a.php
不文明用语<img src=images/xyq/1.gif/>
添加回答
举报