Simple example of php stripslashes and addslashes

WBOY
Release: 2016-07-25 08:59:40
Original
1133 people have browsed it
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);
  }  //递归处理数组,直至遍历所有数组元素;
}
?>
Copy after login


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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!