【发布时间】:2013-10-23 05:39:08
【问题描述】:
同时,我在PHP.net#mysqli_real_escape_string 中阅读了有关mysqli->real_escape_string 的信息。几行,我不明白它们的意思,以及使用real_escape_string时哪个字符集是安全的
注意安全:默认字符集
字符集必须在服务器级别设置,或者使用 影响的 API 函数 mysqli_set_charset() mysqli_real_escape_string()。请参阅有关字符的概念部分 设置以获取更多信息。
有人可以解释一下,utf-8 或 default latin 是否安全:-
这是他们的代码 sn-p 描述这里的情况http://in1.php.net/manual/en/mysqli.real-escape-string.php
这是什么意思?
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
// Will not affect $mysqli->real_escape_string();
$mysqli->query("SET NAMES utf8");
// Will not affect $mysqli->real_escape_string();
$mysqli->query("SET CHARACTER SET utf8");
// But, this will affect $mysqli->real_escape_string();
$mysqli->set_charset('utf8');
?>
谢谢
【问题讨论】:
标签: php mysql character-encoding mysqli