在开发时,我们要注意防止sql注入,所以在对表单提交过来的值要做相应的处理,才可以把数据更新到数据库里
php横扫千军函数。任何值都可以传过来转换
function quotes($content)
{
//如果magic_quotes_gpc=Off,那么就开始处理
if (!get_magic_quotes_gpc()) {
//判断$content是否为数组
if (is_array($content)) {
//如果$content是数组,那么就处理它的每一个单无
foreach ($content as $key=>$value) {
$content[$key] = addslashes($value);
}
} else {
//如果$content不是数组,那么就仅处理一次
addslashes($content);
}
} else {
//如果magic_quotes_gpc=On,那么就不处理
}
//返回$content
return $content;
显示的时候要用 stripslashes ()去掉反斜杠
stripslashes()了,它能把addslashes()处理时自动加上去的(反斜杠)\去掉
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn