preg_replace + UTF-8不能在一台服务器上运行,但可以在另一台服务器上运行 [英] preg_replace + UTF-8 doesn't work on one server but works on another

查看:83
本文介绍了preg_replace + UTF-8不能在一台服务器上运行,但可以在另一台服务器上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

echo preg_match("/\b(בדיקה|מילה)\b/iu", "זוהי בדיקה");

由于某种原因,此代码在我测试过的多台服务器上返回1,但在一台特定服务器上返回0.

For some reason, this code returns 1 on several servers I've tested it on, but 0 on one specific server.

PCRE使用UTF-8支持和Unicode属性支持进行编译.可能是什么问题?

PCRE is compiled with UTF-8 support and Unicode properties support. What could be the issue?

推荐答案

PHP使用的PCRE版本之间可能有所不同.

There may be difference between PCRE versions which PHP use.

PHP和PCRE版本: http://php.net/pcre.installation

PHP and PCRE versions: http://php.net/pcre.installation

您应该使用8.10+(PHP 5.3.4 +)

You should use 8.10+ (PHP 5.3.4+)

版本8.10 2010年6月25日:

  1. 添加了PCRE_UCP以制作\ b,\ d,\ s,\ w和某些POSIX字符类 使用Unicode属性.模式开始处的(* UCP)可用于设置 此选项.修改了pcretest以添加/W来测试此功能.添加 REG_UCP,使其可以通过POSIX接口使用.
  1. Added PCRE_UCP to make \b, \d, \s, \w, and certain POSIX character classes use Unicode properties. (*UCP) at the start of a pattern can be used to set this option. Modified pcretest to add /W to test this facility. Added REG_UCP to make it available via the POSIX interface.

修改: 刚刚进行了一些测试,在PHP 5.3.10上给出了1,在PHP 5.3.2和PHP 5.3.3上给出了0.

Just done some tests and it gives 1 on PHP 5.3.10 and 0 on PHP 5.3.2 and PHP 5.3.3.

这篇关于preg_replace + UTF-8不能在一台服务器上运行,但可以在另一台服务器上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆