Home >Backend Development >PHP Tutorial >Problems with preg_replace function under PHP5.2, php5.2preg_replace_PHP tutorial
preg_replace uses more than the bytes allowed by php5.2 by default, that is, pcre.backtrack_limit and pcre.recursion_limit The size issue.
Since the official release of Discuz! 6.0.0 program, everyone has been busy upgrading, but some plug-ins have problems under 6.0
For example, http://www.discuz.net/viewthread.php?tid=559133 this bank plug-in
A white screen problem will occur after installation in an environment where PHP is 5.2.0 and above
From the perspective of Discuz! users, we need to assist plug-in authors to solve this problem
Let me talk about my solution process. I hope I can give you some suggestions
First: This plug-in can run normally under 5.5, but the screen will be white under 6.0
In order to increase the readability of template cache files, Discuz!6.0 has increased the indentation of cache files, and has indeed modified some template processing parts of templates.func.php,
Could this be the reason? At first, I initially determined that the problem was here, because after replacing the modified code with part of the 5.5 code, it behaved normally, but I was very depressed and could not find the reason
Second step: I suspected that it was a problem with the writing format of the bank.htm template, so I started to analyze the template very depressedly. To be honest, it was really a headache to analyze the template when it was so big. Apparently no reason was found. It’s quite depressing
Second step: Then I found that after splitting this template, it was executed normally. At this time, I initially suspected whether the regular matching bug caused an error when the amount of data was large, so I went to bugs.php. net started searching http://bugs.php.net/search.php?c... ace&x=3&y=5. I searched and searched here, and finally found http://bugs.php.net/bug. php?id=39405, suddenly found that it was a problem with the 5.2 configuration. After adjusting the pcre.backtrack_limit and pcre.recursion_limit, the problem was solved
It is said that pcre.backtrack_limit=-1 in php.ini
There is no limit
The reason I write this in detail is to share my ideas for solving the problem:)