Today, mysql_real_escape_string() is escaping single quotes AND double quotes

前端 未结 2 655
孤街浪徒
孤街浪徒 2021-01-20 01:47
$str = \'BEGIN This is a \"quote\" test. \\\'Single\\\' END\';
echo $str . \"\\n\";
echo mysql_real_escape_string($str);

// Outputs:
BEGIN This is a \"quote\" test.         


        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-20 02:36

    " does start a string in MySQL. (See: Strings)

    Exception:

    If the ANSI_QUOTES SQL mode is enabled, string literals can be quoted only within single quotation marks because a string quoted within double quotation marks is interpreted as an identifier.

提交回复
热议问题