mysql_real_escape_string()
在PHP 5.5.0中被弃用,在PHP 7.0.0中被删除,那么我能用PHP 7.0.7在mysql DB中插入特殊字符吗?
使用addslashes
而不是mysql_real_escape_string()
您可以使用PDO插入特殊字符。让我们看看示例:
<?php
$conn = new PDO('mysql:host=localhost;dbname=form', $username, $password);
/* Complex string */
$string = "Co'mpl''ex '"st''"ring";
print "Unquoted string: $string'n";
print "Quoted string: " . $conn->quote($string) . "'n";
?>