<?php
function check_form($form) {
if(!get_magic_quotes_gpc()) { //get_magic_quotes_gpc()这个函数是检测在PHP.INI中magic_quotes_gpc是否设置
for($i=0;$i<count($form);$i++){ //count是计算变量中元素的个数,从第一个开始判断是不是特殊字符
$form[$i]=addslashes($form[$i]); //如果是特殊字符则用addslashes()函数转换
}
}
return $form; //返回转换好的变量
}
?>
Note: In PHP.ini, MAGIC_QUOTES_GPC and Magic_quotes_runtime are encountered with a special character automatic conversion, if set to on, automatic conversion, if off is the opposite. The difference is that the former is used when the request starts, the latter is used to read data from a file or execute exec () results or from SQL queries, each time the script accesses the data generated in the running state.
Write here suddenly remembered there is a setting, and the above irrelevant, just think up, conveniently recorded here error_reporting (0); setting does not display page error messages.