English 中文(简体)
preg_matchail in php>5.3
原标题:preg_match fails in php > 5.3

我不赞成定期表达,因此我甚至不知道这样做是什么,确切地说:

echo preg_match( /^(([a-zA-Z0-9x2d]{1,63}x2e)*[a-zA-Z0-9x2d]{1,63}){1,254}$/ ,  example12345678.com> );

我从泽德框架的旧版本(1.5)来看,该框架已经过时,在框架的最后稳定版本中,这一框架不再提出。 然而,它的行为是好奇的,因为我没有发现任何文件上的解释,也没有发现在官方的营地资源中存在一个落后的不兼容说明。

事情是,在php5.2.*上,它做的是罚款:收益。 0. On php 5.3.10, 5.4.0 (很可能会 5.3. , 5.4. 我先说的是,它归还了FALSE,即“错误”。

我的问题是:为什么? 错误是什么? 它是reg、某种重新入侵或规则含糊不清吗? 如果是的话,它为什么在php5.2上工作?


有趣的是,如果我改变榜样12345678.com>例如1234567.com> (使其缩短一个或一个以上果园)——它就开始工作和返回。 页: 1 它还运作,返回1。

<>UPD:t. 尚未知道这一事项,但此处的pcre版本是8.02 (php 5.2) 诉8.12 (php 5.3)


www.un.org/Depts/DGACM/index_spanish.htm 我确实理解它会给......带来多少好处,现在没有任何问题要让任何事情发挥作用。 正如我说过的那样,更新的Zend_Validate_* 解决了这一问题。 我试图描述我的关切,即:

也就是说,我提升了一个重要软件,使Sphp5.2 > php5.3转换。 我试图找到关于我可能面临的所有问题的信息(主要通过阅读:)。 该软件是旧的,但不是古老的,例如。 泽德框架可采用1.5版本。 我检查/派遣/分析并固定每个断肢和假肢。 甚至我的单位测试也会受到罚款。

To my surprise what is described in the question happens. (To be precise, Zend_Validate_Hostname there throws an exception). So now I want to know why I missed this one when upgrading and, what s more important, whether I should recheck all preg_match (and other PCRE utilizing functions) in the app trying various imaginable input data in attempt to find similar "bug fixes".

If it is a "bug fix". Because it looks like a new bug - it used to work as expected in php5.2 and doesn t work anymore.

希望获得一些杂货,以缩小搜寻范围。

问题回答

这是很经常的表述。 问题在于,铺设might<>>>>/em>的距离太大,因此,发动机在发现其实际上没有匹配之前,就不忘它们。

Also, it looks like it s trying to match valid domain names, and it doesn t. I would replace that call to preg_match with a call to this function instead:

function is_valid_domain_name($string) {
    if (strlen($string) > 253) {
        return false;
    }
    $label =  (?!-)[a-zA-Z0-9-]{0,63}(?<!-) ;
    return preg_match("/^(?:$label.){0,126}$label$/", $string);
}

它迅速解决你提出的问题:

echo is_valid_domain_name( example12345678.com> ),"
";




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...