Home >Backend Development >PHP Tutorial >preg_match regular matching prompt pcre.backtrack_limit solution_PHP tutorial
This article introduces the solution to the preg_match regular matching prompt pcre.backtrack_limit. Friends in need can refer to it.
Using preg_match to extract the target content, there is a problem with life and death, and the code is dead or alive.
Later I suspected that PHP's preg_match had a string length limit. Sure enough, I found that the value of "pcre.backtrack_limit" was only set to 100000 by default.
Solution:
代码如下 | 复制代码 |
ini_set('pcre.backtrack_limit', 999999999); |
Note: This parameter is available after PHP 5.2.0 version.
Also, let’s talk about:
pcre.recursion_limit
pcre.recursion_limit is the recursion limit of PCRE. If this item is set to a large value, the available stacks of all processes will be consumed, and eventually PHP will crash.
You can also limit it by modifying the configuration: In actual project applications, it is best to limit the memory: ini_set('memory_limit', '64M'); , which is more secure.
The code is as follows
|
Copy code
|
||||
ini_set('pcre.recursion_limit' , 99999);
|
The code is as follows
|
Copy code |