php utf8 html字符,PHP:utf-8编码,htmlentities给出了奇怪的结果
我正在嘗試從POST表單中獲取數(shù)據(jù).當(dāng)用戶輸入“habláis”時(shí),它在視圖源中顯示為“habláis”.我想將其轉(zhuǎn)換為“habl& aacute; is”以進(jìn)行字符串比較,但utf8_encode()和htmlentities()都輸出habl& Atilde;& iexcl;是,而htmlspecialchars()什么都不做.我會(huì)使用str_replace但它在搜索字符串時(shí)不會(huì)識(shí)別á.
我在頁(yè)面上一直使用utf-8的字符集.知道發(fā)生了什么事嗎?
解決方法:
我不確定這是不是你的問(wèn)題,但是你用UTF-8參數(shù)調(diào)用htmlentities嗎?我問(wèn),因?yàn)槟遣皇撬哪J(rèn)值:
Like htmlspecialchars(), it takes an
optional third argument charset which
defines character set used in
conversion. Presently, the ISO-8859-1
character set is used as the default.
所以你可能想嘗試這樣調(diào)用你的函數(shù):
$output = htmlentities($input, ENT_COMPAT, 'UTF-8');
這會(huì)解決您的問(wèn)題嗎?
標(biāo)簽:html,php,utf-8
來(lái)源: https://codeday.me/bug/20190730/1577813.html
總結(jié)
以上是生活随笔為你收集整理的php utf8 html字符,PHP:utf-8编码,htmlentities给出了奇怪的结果的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 分布式锁 哨兵模式_手撕redis分布式
- 下一篇: php设计者,PHP设计者---comp