我正在使用CodeIgniter在多語言網站上工作。有一種形式的數據發佈到控制器,但$_POST
是空的,當我開始使用土耳其語的字符,如öçüÜĞ
等
我的字符集設置爲:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
形式:
<form action="translations/save" method="post" accept-charset="utf-8">
<textarea rows="6" cols="60" id="editor_tr" name="editor_tr">Türkçe</textarea>
</form>
$_POST
和$this->input->post('editor_tr')
返回空,但我可以看到file_get_contents("php://input")
的原始帖子。
這個在正常的PHP測試中工作正常,但不適用於CodeIgniter。也許我的.htaccess文件導致了這個問題,但不知道。
任何幫助,非常感謝。
UPDATE: 下面是var_dump的輸出要求。
var_dump($_POST)
- 如果沒有土耳其字符
array(3) { ["id"]=> string(12) "news8titleID" ["editor_tr"]=> string(13) "turkish value" ["editor_en"]=> string(13) "english value" }
var_dump($_POST)
- 土耳其字符(輸入爲:Türkçe karakter
,但它並沒有在彥博在$顯示)
array(3) { ["id"]=> string(12) "news8titleID" ["editor_tr"]=> string(0) "" ["editor_en"]=> string(13) "english value" }
更新2 : 調試時,我發現system.core.Input
類清除_clean_input_data
函數上的輸入數據。
// Clean UTF-8 if supported
if (UTF8_ENABLED === TRUE)
{
$str = $this->uni->clean_string($str);
}
所以,以前$_POST
已經達到我的控制器,該editor_tr
值已經由system.core.Utf8
類此功能清洗:
function clean_string($str)
{
if ($this->_is_ascii($str) === FALSE)
{
$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
}
return $str;
}
你有沒有試過mbstring?和[codeigniter]的相關修復(http://www.haughin.com/2010/02/23/building-utf8-compatible-codeigniter-applications/) – 2011-04-25 23:28:35
'我的.htaccess文件可能是導致此問題,但不知道。考慮提供它呢? – Khez 2011-04-25 23:30:06
@Madmartigan對不起,這是一個錯字。 – Ozay 2011-04-26 08:11:48