Home >php教程 >php手册 >PHP 防止sql注入函数代码

PHP 防止sql注入函数代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 10:41:231090browse

PHP 防止sql注入函数代码:

  1. $magic_quotes_gpc = get_magic_quotes_gpc();
  2. @extract(daddslashes($_COOKIE));
  3. @extract(daddslashes($_POST));
  4. @extract(daddslashes($_GET));
  5. if(!$magic_quotes_gpc) {
  6.         $_FILES = daddslashes($_FILES);
  7. }
  8. function daddslashes($string, $force = 0) {
  9.         if(!$GLOBALS[magic_quotes_gpc] || $force) {
  10.                 if(is_array($string)) {
  11.                     foreach($string as $key => $val) {
  12.                         $string[$key] = daddslashes($val, $force);
  13.                     }
  14.                 } else {
  15.                     $string = addslashes($string);
  16.                 }
  17.         }
  18.         return $string;
  19. }
  20. ?>
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