dongxin8392 2010-07-20 12:05
浏览 142

使用preg_replace在单引号前添加反斜杠

How to add a backslash before single quotes using preg_replace() php function ?

  • 写回答

2条回答 默认 最新

  • douzhe3516 2010-07-20 12:08
    关注

    In case you are not trying to escape Database input:

    $string = str_replace("'", "\\'", $string);
    

    In case you are:

    Please consider using the appropriate escaping function. (E.g. mysql_real_escape_string) or just use prepared statements.

    评论

报告相同问题?