php stripslashes() addslashes() 解析
stripslashes() 函数删除由 addslashes() 函数添加的反斜杠。
实例:
<?php $str = "Is your name O\'reilly?"; // Outputs: Is your name O'reilly? echo stripslashes($str); ?>
输出:
Who's John Adams?
addslashes() 函数在指定的预定义字符前添加反斜杠。
这些预定义字符是:
- 单引号 (')
- 双引号 (")
- 反斜杠 (\)
实例:
<?php $str = "Who's John Adams?"; echo $str . " This is not safe in a database query.<br />"; echo addslashes($str) . " This is safe in a database query."; ?>
结果:
Who's John Adams? This is not safe in a database query.
Who\'s John Adams? This is safe in a database query.
没有无缘无故的荣耀
赞助我写出更好的博客
赞助我写出更好的博客