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

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.";
?>

输出:

Whos John Adams? This is not safe in a database query.
Who\s John Adams? This is safe in a database query.

 

stripslashes() 例子:

<?php
echo stripslashes("Who\‘s John Adams?");
?>

输出:

Whos John Adams?

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。