PHP preg_match停止响应字符串中的特定字符数

时间:2015-03-13 23:06:15

标签: php regex preg-match

是否存在某种PHP配置设置会影响传递给preg_match或preg_match_all的字符串的长度?

我有以下内容,我正在尝试测试以解决我的问题:

    $re = "/\[\[section\:(.*?)\]\]((.|\n)*?)\[\[endsection\]\]/"; 
    $str = "[[section:body]]
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    lots of lines here
    [[endsection]]

    other stuff here"; 

    preg_match_all($re, $str, $matches);
    var_dump($matches);

现在如果我运行它很好,它会立即返回结果。

但是如果我再添加一行到$ str变量并再次运行它,它只是旋转和旋转然后我得到的网页无法显示。

但是,如果我在writecodeonline.com/php上运行完全相同的东西,它可以正常工作并立即返回。

我的php错误日志或我的apache错误日志中没有出现任何错误,只要它碰到某些字符就会拒绝执行任何操作(看起来只要它碰到 707 字符停止响应。

之前有没有人遇到过这类问题?是否只需要更改一些配置设置?

干杯。

1 个答案:

答案 0 :(得分:0)

是的,有the backtrack-limit

您可以在php.ini文件中配置它。

说实话,快速google search会解决你的问题......