我有一些PHP应用程序的代码,在生产服务器上使用时返回null,但在开发服务器上可以正常工作。以下是代码行:
// use the regex unicode support to separate the UTF-8 characters into an array
preg_match_all( '/./us', $str, $match );
“u”标志依赖于什么?我测试了启用和禁用“mb_string”,似乎没有影响。
我收到的错误是:
preg_match_all: Compilation failed: unknown option bit(s) set at offset -1
更多信息
这是生产服务器上的选项之一:
'--with-pcre-regex=/opt/pcre'
这里是pcre部分
我相信这是@Wesley提到的那个注释:
In order process UTF-8 strings, you must build PCRE to include UTF-8
support in the code, and, in addition, you must call pcre_compile()
with the PCRE_UTF8 option flag, or the pattern must start with the
sequence (*UTF8). When either of these is the case, both the pattern
and any subject strings that are matched against it are treated as
UTF-8 strings instead of strings of 1-byte characters.
有没有关于如何“构建包含UTF-8的PCRE”的链接或提示?
pcretest -C
的结果
PCRE version 6.6 06-Feb-2006
Compiled with
UTF-8 support
Unicode properties support
Newline character is LF
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack