我看不出有什么不同。
表定义:
create table test (s text)
PHP测试源码:
<?php
$variable = <<<eot
"asdasd" hello 'name name'
//
\\
"end"
eot;
// mysql version
$conn = mysql_connect('localhost', 'USERNAME', 'PASSWORD');
mysql_select_db('test', $conn);
$sql = "insert into test values ('" . mysql_escape_string($variable) . "')";
$result = mysql_query($sql, $conn);
// mysqli version
$conn = mysqli_connect('localhost', 'USERNAME', 'PASSWORD', 'test');
$sql = "insert into test values ('" . mysql_escape_string($variable) . "')";
$result = mysqli_query($conn, $sql);
// mysqli version (prepared statement)
$conn = new mysqli('localhost', 'USERNAME', 'PASSWORD', 'test');
$sql = 'insert into test values (?)';
$sth = $conn->prepare($sql);
$sth->bind_param('s', $variable);
$result = $sth->execute();
每个版本都会在表中生成相同的条目。所以,要么这只是你拥有的不同输出,要么你的代码做了不同的事情。