宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应

PHP关于反斜杠处理函数addslashes()和stripslashes()的用法

2016-10-13 00:16:48 点击量:21 标签: 收藏本文

addslashes() 例子:

  1. <?php 
  2. $str = "Who's John Adams?"
  3. echo $str . " This is not safe in a database query.<br />"; 
  4. echo addslashes($str) . " This is safe in a database query."; 
  5. ?> 

输出: 

  1. Who's John Adams? This is not safe in a database query. 
  2. Who\'s John Adams? This is safe in a database query. 

stripslashes() 例子:

 

  1. <?php 
  2. echo stripslashes("Who\'s John Adams?"); 
  3. ?> 

输出:

  1. Who's John Adams? 

PHP关于反斜杠处理函数addslashes()和stripslashes()的用法