我目前正在對kruti開發010字體 我的字符串包含HTML數像PHP字符串包含HTML號的特殊字符代碼
& #39; ,& amp;,& quot;
我想這個詞轉化爲「&」
<?php
$string="my string with '";
echo html_entity_decode($string); //not working
?>
我要像
輸出我目前正在對kruti開發010字體 我的字符串包含HTML數像PHP字符串包含HTML號的特殊字符代碼
& #39; ,& amp;,& quot;
我想這個詞轉化爲「&」
<?php
$string="my string with '";
echo html_entity_decode($string); //not working
?>
我要像
輸出行情總是快速障礙,當你第一次跟他們試試這個。訣竅是將ENT_QUOTES添加到該函數中。見htmlspecialchars_decode
<?php
$string="my string with '";
echo htmlspecialchars_decode("my string with '" , ENT_QUOTES);
?>
注:分號在被解碼的性格到底是不是必要的,但總體認爲良好的姿勢。它被排除在外以更好地匹配OPs -original-code。
有趣的是,我發現將'ENT_QUOTES'選項添加到參數列表中是沒有什麼區別的。我的[phpfiddle](http://phpfiddle.org/main/code/qhrb-n50n)在兩種情況下返回相同的結果。提示:看看頁面源代碼,你也會看到,在這兩種情況下,&符號仍然編碼爲'&'。 – cars10m
<?php
$string="my string with '";
echo html_entity_decode($string); //not working
?>
你忘了分號
$string="my string with '";
請試試你的答案您發佈之前, 。 – ElefantPhace
即使它不起作用,他是正確的,OP忘了分號 – Mike
不在電腦。很難在移動設備上進行測試。但是,謝謝你的提示,我通常首先測試。 – Pazuzu156
嘗試在PHP腳本的開頭調用header('Content-Type: text/html; charset=utf-8');
或將AddDefaultCharset UTF-8
添加到您的.htaccess
文件中。
$ config ['charset'] ='UTF-8';已在codeigniter框架中啓用 – daulat
&#39'如何將字符串 – daulat
內轉換'回聲htmlspecialchars_decode(‘我的字符串'’,ENT_QUOTES);'注重'ENT_QUOTES' – Rasclatt
感謝名單這是工作 – daulat