时间:2021-07-01 10:21:17 帮助过:7人阅读
$sql="select * from demo where user='".$_POST['user']."'"";
$sql="select * from demo where user='".addslashes($_POST['user'])."'"";
$sql="select * from demo where user='".$_POST['user']."'"";
$_POST=array_map("addslashes",$_POST);
$_POST['user']="demo";
$_POST['content']="Hello,It's a book";
$_POST=array_map("addslashes",$_POST);
echo "";
var_dump($_POST);
?>
打印出来的结果array(2) {
["user"]=>
string(4) "demo"
["content"]=>
string(18) "Hello,It\'s a book"
}
------解决方案--------------------
所以要这样写$a = array(
'a' => "a'b",
'b' => array("C'd", 123)
);
array_walk_recursive($a, function(&$v) { $v = addslashes($v); });
print_r($a);Array
(
[a] => a\'b
[b] => Array
(
[0] => C\'d
[1] => 123
)
)