我在PHP应用程序中有一些代码,当我尝试在生产服务器上使用它时返回null,但它在开发服务器上正常工作。这里是行代码:什么是preg_match_all“u”标志依赖于?
// 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
更多信息
这是对prodction服务器上的其中一个选项:
'--with-pcre-regex=/opt/pcre'
这里是pcre部分
Picture.png http://img829.imageshack.us/img829/8524/pictureke.png
我相信这是音符@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.
如何 “打造PCRE包括UTF-8” 的任何链接或提示?的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
您是否正在测试变量或常量值?你的例子有一个变量,我认为你应该测试一个常数,以确保你在开发和生活上都做得相同。 – hakre
http://php.net/manual/en/reference.pcre.pattern.modifiers.php,请参阅评论。 –