PHP – 使用 mb_http_output() 獲取或設定 HTTP 輸出字元編碼
PHP 中的 mb_http_output() 函式用於獲取或設定 HTTP 輸出字元編碼。此函式在呼叫後,輸出將從設定的內部編碼轉換為指定的編碼。
語法
string|bool mb_http_output(str $encoding = null)
引數
mb_http_output() 僅接受一個引數 −
$encoding − 用於將 HTTP 輸出字元編碼設定為 編碼。如果省略編碼,則 mb_http_output() 將返回當前 HTTP 輸出字元編碼。
返回值
如果省略編碼,那麼 mb_http_output() 函式將返回當前的 HTTP 輸出字元編碼。否則,它將返回 True 表示成功,False 表示失敗。
示例
<?php // It will return the output character encoding $string = mb_http_output(); var_dump($string); ?>
輸出
它將產生以下輸出 −
string(5) "UTF-8"
廣告