PHP function that formats data to prevent injection

WBOY
Release: 2016-07-25 09:03:45
Original
1004 people have browsed it
  1. //Format data (prevent injection)
  2. function site_addslashes($string, $force = 0) {
  3. !defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc()) ;
  4. if(!MAGIC_QUOTES_GPC || $force) {
  5. if(is_array($string)) {
  6. foreach($string as $key => $val) {
  7. $string[$key] = daddslashes($val, $force);
  8. }
  9. } else {
  10. $string = addslashes($string);
  11. }
  12. }
  13. return $string;
  14. }
  15. ?>
Copy code

In addition to the above methods, it is recommended that everyone Refer to the anti-injection function of discuz.



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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template