您的位置:首页 > 编程语言 > PHP开发

php magic_quotes_runtime 和 magic_quotes_gpc的区别

2011-11-24 14:50 495 查看
自 PHP 5.3.0 起,magic_quotes_runtime(),ereg() 函数已被废弃,不再使用。报错例如:Deprecated: Function set_magic_quotes_runtime() is deprecated表明已被废弃。改函数的作用是对大多数函数返回数据,任何形式的外部来源包括数据库和文本文件里的数据将被转义,引用手册上的原话:If magic_quotes_runtime is enabled, most functionsthat return data from any sort of external source including databases and textfiles will have quotes escaped with a backslash. If magic_quotes_sybase is alsoon, 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); }

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: