What is the equivalent javascript code for php's mysql_real_escape_string()?
问题 What is the equivalent javascript code for mysql_real_escape_string() ? 回答1: Based on the PHP documentation of the method this would do roughly the same thing. The method mysql_real_escape_string in PHP is deprecated however. function mysqlEscape(stringToEscape){ return stringToEscape .replace("\\", "\\\\") .replace("\'", "\\\'") .replace("\"", "\\\"") .replace("\n", "\\\n") .replace("\r", "\\\r") .replace("\x00", "\\\x00") .replace("\x1a", "\\\x1a"); } Unfortunately that's not exactly what