我在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,請參閱評論。 –