Php 在MySQL之前转义引号
这里我有一个脚本来验证用户传递的描述:Php 在MySQL之前转义引号,php,mysql,security,Php,Mysql,Security,这里我有一个脚本来验证用户传递的描述: if(strlen($_POST['descriprtion']) >250) { //Some error code here } else { $description = $mysqli->escape_string(htmlentities(trim($_POST['description']))); } 现在,我用我正在测试的的描述进行测试。当我打印页面时,我会给我这样的东西: 如你所见,在单引号前有一条黑色斜线 我正在
if(strlen($_POST['descriprtion']) >250) {
//Some error code here
} else {
$description = $mysqli->escape_string(htmlentities(trim($_POST['description']))); }
现在,我用我正在测试的的描述进行测试。当我打印页面时,我会给我这样的东西:
如你所见,在单引号前有一条黑色斜线
我正在考虑使用stripslashes()
,但是我应该在哪里使用它呢 要回显变量时,请使用stripslashes()
echo $var; // --> I\'m testing. Not funny.
echo stripslashes($var); // --> I'm testing. Not funny.
可能是的副本。谢谢。我刚才也换成了准备好的陈述。尽管我没有逃脱。它仍然返回斜杠。所以基本上,我仍然需要stripslashes
并使用准备好的语句