多年来,我所有的php脚本都使用UTF8编码,没有BOM,它们工作得很好。今天我发现有一个名为zend.multibyte的核心指令,默认情况下它是零(禁用)。
因此,如果它不影响脚本解析..它到底影响了什么?
发布于 2013-06-18 22:59:57
Zend Multibyte对于ASCII不兼容的编码是必需的,比如一些来自之前unicode/pre-utf-8的亚洲编码,并且主要在日本使用。启用后,解析器将检查mbstring.script_encoding,并在解析时使用该编码。由于在内部发生了一些转换,应该避免这种情况,但对于一些用户来说,这是他们使用PHP的唯一方式。
发布于 2020-09-20 14:58:31
它的重点是影响脚本解析。如约翰尼斯所说,一个目的是用于与ASCII不兼容的编码。(UTF-8与ASCII兼容,这就是您不需要它的原因。)
但它也可以用于在编译时透明地转换脚本编码。假设由于某种原因,您的文本编辑器只能保存为ANSI,但是您需要您的代码才能看到UTF-8。打开zend.multibyte并将脚本的编码声明为windows1252将允许您将脚本编码为ANSI,并且PHP将透明地将包含在脚本中的字符串文字从ANSI转换为php.ini的internal_encoding指令中设置的编码(默认值为UTF-8)。由于这是在编译时发生的,因此对于您的代码,您的脚本将全部包含UTF-8。
你可以通过两种方式声明你的脚本的编码。
通过在php.ini
来自php.ini:
; If enabled, scripts may be written in encodings that are incompatible with
; the scanner. CP936, Big5, CP949 and Shift_JIS are the examples of such
; encodings. To use this feature, mbstring extension must be enabled.
; Default: Off
;zend.multibyte = Off
; Allows to set the default encoding for the scripts. This value will be used
; unless "declare(encoding=...)" directive appears at the top of the script.
; Only affects if zend.multibyte is set.
; Default: ""
;zend.script_encoding =https://stackoverflow.com/questions/17170890
复制相似问题