我为我的 mysql 连接使用面向对象的样式,但是如果我这样写:
array_walk_recursive($_POST, array($mysqli, 'real_escape_string'));
我收到此错误:
Warning: mysqli::real_escape_string() expects exactly 1 parameter, 2 given
事实是mysqli::escape_string只接受1 个参数:
string mysqli::escape_string ( string $escapestr )
我写的:
$VAR = array();
$VAR = $_POST;
function escape_string($item, $key) {
$arr[$key] = $mysqli->real_escape_string($item);
}
array_walk_recursive($VAR, 'escape_string');
我得到这个错误:
Fatal error: Call to a member function real_escape_string() on a non-object