Home >Backend Development >PHP Tutorial >PHP preg_match matching string length problem
In the project, there has been a problem using preg_match to extract the target content. At first, I felt that 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. 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: ini_set('pcre.recursion_limit', 99999); The editor of Programmer Home reminds that in actual project applications, it is best to limit the memory: ini_set('memory_limit', '64M'); , which is safer. |