我有一个文本区域,我想接受文本区域的输入并将它们合并在一起.一切正常,但它正在逃避报价.例如,测试输出为test /’s
为了解决这个问题,我试过了很多例子,
<?PHP $inputtext= $_POST['textinput'];
$encodetext = htmlentities($inputtext);
$finaltext = html_entity_decode($encodetext);
echo '<p>'.$finaltext .'</p>'; ?>
这应该按照html_entity_decode手册工作(除非我读错了,很可能就是这种情况)
解决方法:
当数据来自POST或GET时,会自动添加斜杠.这被称为魔术引号,默认情况下已启用.
您可以使用stripslashes()删除这些斜杠
<?PHP
$text = $_POST['txtarea']; // from textarea
if(get_magic_quotes_gpc()){
$text = stripslashes($text);
// strip off the slashes if they are magically added.
}
$text = htmlentities($text);
// what htmlentities here does is really to convert:
// & to &
// " to '
// and change all < and > to < and > respectively. this will automatically disable html codes in the text.
echo '<pre>'.$text.'</pre>';
?>
见:http://php.net/manual/en/function.stripslashes.php
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。