加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 使用htmlentities方法时的编码问题

发布时间:2020-12-13 17:05:46 所属栏目:PHP教程 来源:网络整理
导读:我在php中有字符编码的问题,所以这是php代码: n_event=$_GET['ndlann'];$nom_complet=htmlentities(stripslashes($_POST['nom']));$email_comment=htmlentities(stripslashes($_POST['email']));$titre_comment=htmlentities(stripslashes($_POST['titre'])
我在php中有字符编码的问题,所以这是php代码:

n_event=$_GET['ndlann'];
$nom_complet=htmlentities(stripslashes($_POST['nom']));
$email_comment=htmlentities(stripslashes($_POST['email']));
$titre_comment=htmlentities(stripslashes($_POST['titre']));
$texte_comment=htmlentities(stripslashes(nl2br($_POST['commentaire'])));
$pays_comment=$_POST['pays'];
$date_ajout=date('Y/m/d');

数据将添加到数据库表中,您会看到此数据来自评论表单,
因此,当用户使用东方语言carachters(阿拉伯语,希伯来语等)输入一些注释时,输入数据将更改为:

?′ù??±?§ ?1ù?ù? ?§ù?ù?ù???ù??

我试图删除htmlentities方法,并且工作正常,但确实启动了另一个注释形式安全问题(将执行js脚本)

这种情况怎么办?

并谢谢

解决方法

不要使用htmlentities().

这个功能很久以前就已经过时了.
请改用htmlspecialchars().

你的代码中也有一堆废话

>做htmlentities(nl2br(*))毫无意义.>只有在设置了魔术引号时才会使条带条件有条件.>付款领域可能存在问题.>我也担心你会把某些SQL升级函数作为一种新的功能.我对吗?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读