Home > php教程 > php手册 > PHP addslashes 的高级写法

PHP addslashes 的高级写法

WBOY
Release: 2016-06-13 10:12:20
Original
1028 people have browsed it

本文章介绍了用户自定义的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;
 }
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template