Home > Article > Backend Development > Solving the problem of preg_match long string matching failure in PHP_PHP tutorial
The article introduces a problem often encountered in PHP development. Preg_match fails to match long strings. Students who have encountered the same problem can refer to it.
The string is relatively long, so I wonder if preg_match also has a string length limit, and sure enough!
This will happen with preg_match and preg_match_all.
Solution:
1. ini_set(‘pcre.backtrack_limit’, 1000000); //The default is only 100000
2. Modify the pcre.backtrack_limit parameter of php.ini to support larger strings. Add configuration: pcre.backtrack_limit=-1