可以用str_replace()来进行替换
或者用addslashes()来为引号加上斜杠
或者把PHP。INI中的MAGIC_QUOTES_GPC设为on

解决方案 »

  1.   

    忘记说一点可以用intval()来过滤,如果你的id是数字的话
      

  2.   

    欢迎加入PHP  WAP QQ群8352641   大家一起交流,一起进步.共同发展
      

  3.   

    <? 
    function  strReplace($string){
    $text=$string;
    $text=str_replace(">","&gt;",$text);
    return $text;
    }
    $content=strReplace("<a href='newshow.php?id=$arr[id]' target='_blank'>$arr[title]</a>");
     echo "$content" ;
     ?> 这么写以后报错:Fatal error: Cannot redeclare strreplace() (previously declared in D:\Program Files\Apache2\htdocs\news\shownews.php:97) in D:\Program Files\Apache2\htdocs\news\shownews.php on line 97
    97行是function  strReplace($string){哪里出错了呢?
      

  4.   

    strreplace() 
    =>
    str_replace()
      

  5.   

    你报的错是重复定义。别的地方已经有strreplace了
      

  6.   

    str_replace()
    替换成双引号就可以了
      

  7.   

    http://blog.csdn.net/heiyeshuwu/archive/2005/06/14/394225.aspx