Home >Backend Development >PHP Tutorial >Escape the variables passed in by the user, excerpted from the ecshop_PHP tutorial

Escape the variables passed in by the user, excerpted from the ecshop_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:30:541080browse

Escape the variables passed in by the user, taken from ecshop.

/* 对用户传入的变量进行转义操作。*/
if (!get_magic_quotes_gpc()){
    if (!empty($_GET)){$_GET  = addslashes_deep($_GET);}
    if (!empty($_POST)){$_POST = addslashes_deep($_POST);}
    $_COOKIE   = addslashes_deep($_COOKIE);
    $_REQUEST  = addslashes_deep($_REQUEST);
}
/* 递归方式的对变量中的特殊字符进行转义*/
function addslashes_deep($value){return empty($value)?$value:is_array($value) ? array_map('addslashes_deep', $value) : addslashes($value);}

Articles you may be interested in

  • Competition of PHP's four methods of serializing variables
  • According to the email entered by the user Jump to the corresponding email homepage
  • How to check MySQL startup time and how long it has been running
  • Image enlargement display special effect slimbox The most lightweight and powerful Jquery image enlargement effect
  • Powerful PHP image processing classes (watermark, transparency, zoom, sharpen, rotate, flip, cut, reverse color)
  • Using php functions in smarty templates and how to modify a smarty template Variables use multiple functions
  • Use PHP's GZip compression function to compress website JS and CSS files to speed up website access
  • How does PHP determine whether the current operating system is linux or windows

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764179.htmlTechArticleEscape the variables passed in by the user, excerpted from ecshop. /* Escape the variables passed in by the user. */if (!get_magic_quotes_gpc()){ if (!empty($_GET)){$_GET = addsla...
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