Home  >  Article  >  Backend Development  >  Simple example of php stripslashes and addslashes

Simple example of php stripslashes and addslashes

WBOY
WBOYOriginal
2016-07-25 08:59:401179browse
Introducing a simple example of the application of php stripslashes and addslashes. Friends in need can refer to it.

The code is as follows:

<?php
/**
* stripslashes与addslashes 应用举例
* Edit bbs.it-home.org
*/
//去除转义方法
 public function mystrip($data){
    if (is_array($data)){
       foreach ($data as &$v){
          $this->mystrip(&$v);
       }
     }else{
    $data = stripslashes($data);
     }
 }
 //加上转义
 function addslashes_deep($value) {
  if (empty($value)) {
      return $value;  //如为空,直接返回;
  } else {
      return is_array($value) ? array_map('addslashes_deep', $value): addslashes($value);
  }  //递归处理数组,直至遍历所有数组元素;
}
?>


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