Home  >  Article  >  Backend Development  >  PHP addslashes 的高级写法_PHP教程

PHP addslashes 的高级写法_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:10:39960browse

本文章介绍了用户自定义的addslashes函数,他可以自动过滤,post,get过来的非法数据哦。

 代码如下 复制代码
@set_magic_quotes_runtime(0);
 $MQG = get_magic_quotes_gpc();
 
 if(!$MQG && $_POST) $_POST = daddslashes($_POST);
 if(!$MQG && $_GET) $_GET = daddslashes($_GET);
 
 //转译字符函数
 function daddslashes($string) {
     if(!is_array($string)) return addslashes($string);
     foreach($string as $key => $val) $string[$key] = daddslashes($val);
     return $string;
 }

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/629651.htmlTechArticle本文章介绍了用户自定义的addslashes函数,他可以自动过滤,post,get过来的非法数据哦。 代码如下 复制代码 @set_magic_quotes_runtime(0); $MQG = get_m...
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