Home >Backend Development >PHP Tutorial >Advanced writing method of PHP addslashes_PHP tutorial
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; } |