[英]Not encoding already encoded items with htmlentities
我有一個看起來像這樣的字符串:
Bürstner
當我對它使用htmlentities()時,我將double encode
參數設置為false,但它仍然會重新編碼
進入 
我用它來編碼:
$out = htmlentities($string,ENT_NOQUOTES, 0);
我在某種程度上誤解了這是如何工作的? 所需的輸出是對變音符號u進行編碼,但僅保留現有的實體(這只是一個例子,已經在很長的文檔中有很多實體)。
**編輯**
由於這似乎不清楚,原始字符串:
Bürstner
期望的輸出:
Bürstner
應該保留現有實體。
htmlentities
的第三個參數是charset參數; 第四個參數是double_encode參數。 試試這個:
$out = htmlentities($string, ENT_NOQUOTES, ini_get('default_charset'), false);
第三個論點是字符集; 你需要將第四個而不是第三個設置為false。
htmlentities的第三個參數是charset ..你需要將4th設置為false
string htmlentities(string $ string [,int $ quote_style = ENT_COMPAT [,string $ charset [,bool $ double_encode = true]]])
看看這個功能
它的鏈接http://php.net/manual/de/function.htmlspecialchars.php
<?php
function special_formatting($input) {
$output = htmlspecialchars($input, ENT_QUOTES);
$output = str_replace(array(' ', "\n"), array(' ', '<br>'), $output);
return str_replace(' ', ' ', $output);
}
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.