PHP之mb_internal_encoding使用


mb_internal_encoding

  • (PHP 4 >= 4.0.6, PHP 5, PHP 7)
  • mb_internal_encoding — Set/Get internal character encoding
  • 設置或獲取內部字符集

Description

mixed mb_internal_encoding ([ string $encoding = mb_internal_encoding() ] )
//Set/Get the internal character encoding

Parameters

encoding

encoding is the character encoding name used for the HTTP input character encoding conversion, HTTP output character encoding conversion, and the default character encoding for string functions defined by the mbstring module. You should notice that the internal encoding is totally different from the one for multibyte regex.

字符編碼用於HTTP輸入,輸出字符編碼轉換,默認的字符編碼由mbstring模塊字符串函數定義的。你應該注意到內部編碼完全不同於多字節的正則表達式。

Return Values

If encoding is set, then Returns TRUE on success or FALSE on failure. In this case, the character encoding for multibyte regex is NOT changed. If encoding is omitted, then the current character encoding name is returned.

如果設置了編碼,則成功返回TRUE或失敗時返回FALSE。在這種情況下,對多字節字符編碼不改變正則表達式。如果省略編碼,則返回當前字符編碼名稱。

Examples

<?php
/**
 * Created by PhpStorm.
 * User: zhangrongxiang
 * Date: 2018/1/26
 * Time: 下午10:18
 */

/* Set internal character encoding to UTF-8 */
mb_internal_encoding("UTF-8");
/* Display current internal character encoding */
echo mb_internal_encoding().PHP_EOL; // UTF-8

mb_internal_encoding("GBK");
echo mb_internal_encoding().PHP_EOL; //CP936
mb_internal_encoding("CP936");
echo mb_internal_encoding().PHP_EOL; //CP936

mb_internal_encoding("iso-8859-1");
echo mb_internal_encoding().PHP_EOL; //ISO-8859-1

文章參考

轉載注明出處


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM