Home >Backend Development >PHP Tutorial >Advanced writing method of PHP addslashes_PHP tutorial

Advanced writing method of PHP addslashes_PHP tutorial

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

This article introduces the user-defined addslashes function, which can automatically filter, post, and get illegal data.

 代码如下 复制代码
@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.htmlTechArticleThis article introduces the user-defined addslashes function, which can automatically filter, post, and get illegal data. . The code is as follows Copy the code @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