What is the character set if default_charset is empty

前端 未结 2 1491
伪装坚强ぢ
伪装坚强ぢ 2021-01-19 05:34

In PHP 5.6 onwards the default_charset string is set to \"UTF-8\" as explained e.g. in the php.ini documentation. It says that the string is empty

2条回答
  •  孤街浪徒
    2021-01-19 05:38

    It seems you should not rely on the internal encoding. The internal character encoding can be seen/set with mb_internal_encoding.

    example phpinfo()

    • PHP Version 5.5.9-1ubuntu4.5
    • default_charset no value

    file1.php

    file2.php

    both files will output ISO-8859-1 if you do not change the internal encoding manually.

    Getting the hex of this character returns UTF-8 encoding. If you save the file using UTF-8 the string in this example will have 2 bytes, even if the internal encoding is not set to UTF-8. Therefore you should rely on the character encoding used for the source file.

提交回复
热议问题