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 |