Platform:
System version: OS X Yosemite 10.10.1
Kernel version: Darwin 14.0.0
PHP code (the encoding of the file is UTF-8)
$str = '自此直至2010年n'; preg_match_all('/(\w+)/u', $str, $matches);print_r($matches[0]);
PHP 5.5.14 (mac Default)
PCRE Edition: PCRE Library version 8.02 2010-03-19
Output:
Array( [0] => 2010 [1] => n)
PHP 5.4.36 (Brew installation)
PCRE Edition: PCRE Library version 8.32 2012-11-30
Output:
Array( [0] => 自此直至2010年n)
May I ask how the differences between the 2 versions are avoided?
Reply content:
Platform:
System version: OS X Yosemite 10.10.1
Kernel version: Darwin 14.0.0
PHP code (the encoding of the file is UTF-8)
$str = '自此直至2010年n'; preg_match_all('/(\w+)/u', $str, $matches);print_r($matches[0]);
PHP 5.5.14 (mac Default)
PCRE Edition: PCRE Library version 8.02 2010-03-19
Output:
Array( [0] => 2010 [1] => n)
PHP 5.4.36 (Brew installation)
PCRE Edition: PCRE Library version 8.32 2012-11-30
Output:
Array( [0] => 自此直至2010年n)
May I ask how the differences between the 2 versions are avoided?
u
just get rid of the modifier, demo:http://3v4l.org/c0469.
U (PCRE_UTF8)
This modifier opens an additional feature that is incompatible with Perl. The pattern string is considered to be utf-8. This modifier is available from the UNIX version of PHP 4.1.0 or higher, Win32 version of PHP 4.2.3. PHP 4.3.5 starts checking the utf-8 legitimacy of the pattern.
-Pattern modifiers