簡體   English   中英

帶有默認字符集的PHP 5.6 HTML實體

[英]PHP 5.6 htmlentities with default charset

我們使用PHP 5.6.5,是從5.3遷移過來的。 htmlentities出現一個問題,該問題沒有采用設置的默認字符集。

因為我必須設置它,因為現在default_charset是“ UTF-8”,所以我遇到了這個問題:

ini_set("default_charset", "ISO-8859-1");
$foo = "in french: sécurité"; //that is in UTF-8

//this is not the same...
$new_foo1 = htmlentities( $foo );
//return empty string

//...as this
$new_foo2 = htmlentities( $foo, ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
//return it correctly

該文檔明確指出:

string htmlentities ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = ini_get("default_charset")

它應該獲取默認字符集。

謝謝

我在PHP.INI文件中設置了default_charset,它解決了問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM