自 PHP 5.3.0 起,magic_quotes_runtime(),
ereg()
函数已被废弃,不再使用。
报错例如:
Deprecated: Function set_magic_quotes_runtime() is deprecated
表明已被废弃。
改函数的作用是对大多数函数返回数据,任何形式的外部来源包括数据库和文本文件里的数据将被转义,
引用手册上的原话:
If
magic_quotes_runtime is enabled, most functions that return data from any sort of external source including databases and text files will have quotes escaped with a backslash. If
magic_quotes_sybase is also on, a single-quote is escaped with a single-quote instead of a backslash.
开启
magic_quotes_gpc()函数,主要是对$_GET,$_POST,$_COOKIE数组里的函数自动转义,通常做法是判断改函数是否开启,如果没有则,用addslashes()函数进行转义。
if(!get_magic_quotes_gpc()){
$_GET = addslashes($_GET);
$_POST = addslashes($_POST);
$_COOKIE = addslashes($_COOKIE);
$_FILES = addslashes($_FILES);
}
转载于:https://blog.51cto.com/myceo/723636