Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php mbstring.strict\u检测的作用是什么?_Php_Configuration_Mbstring - Fatal编程技术网

Php mbstring.strict\u检测的作用是什么?

Php mbstring.strict\u检测的作用是什么?,php,configuration,mbstring,Php,Configuration,Mbstring,mbstring PHP模块具有严格的检测设置。不幸的是,手册是完全无用的;它只说该选项“启用严格的编码检测” 我做了一些测试,没有发现mbstring函数是如何受此影响的。并对有效和无效UTF-8输入给出完全相同的结果 (编辑:)PHP 5.1.2中添加了mbstring.strict_detection选项。如果不设置strict参数,编码检测速度会更快,但不会那么准确。例如,如果您有一个UTF-8字符串,其部分UTF-8序列如下: $s = "H\xC3\xA9ll\xC3"; $enco

mbstring PHP模块具有
严格的检测设置。不幸的是,手册是完全无用的;它只说该选项“启用严格的编码检测”

我做了一些测试,没有发现mbstring函数是如何受此影响的。并对有效和无效UTF-8输入给出完全相同的结果

(编辑:)PHP 5.1.2中添加了
mbstring.strict_detection
选项。

如果不设置strict参数,编码检测速度会更快,但不会那么准确。例如,如果您有一个UTF-8字符串,其部分UTF-8序列如下:

$s = "H\xC3\xA9ll\xC3";
$encoding = mb_detect_encoding($s, mb_detect_order(), false);
mb\u detect\u encoding
调用的结果仍然是“UTF-8”,即使它不是有效的UTF-8(最后一个字符不完整)

但是如果您将strict参数设置为true

$s = "H\xC3\xA9ll\xC3";
$encoding = mb_detect_encoding($s, mb_detect_order(), true);

它将执行更彻底的检查,调用的结果将为FALSE。

没错,但设置
mbstring.strict\u detection
不会影响该行为(甚至$strict参数的默认值也不会)。它对我有效。如果
mbstring.strict\u detection=On
strict参数的默认值为true。请注意,这仅在PHP 5.1.2.Ah之后才可用。没错,如果缺少第三个参数,它确实会影响
mb\u detect\u encoding()
。我在考试中出错了;只有
mb\u check\u encoding()
mb\u convert\u encoding()
不受影响。非常感谢。