There will be some problems in the strings matched by preg_match. Let me introduce to you how to solve the problem of wrong views when long strings.
Example
preg_match_all regular match string all connection addresses
The code is as follows
代码如下 |
复制代码 |
$str ='4
5
6
';
$ymd=date("y")."/".date("m-d");
$b = preg_match_all('/(.*?)/',$a,$c,preg_set_order);
|
|
Copy code
|
$str ='4
5
6
';
$ymd=date("y")."/".date("m-d");
代码如下 |
复制代码 |
ini_set(‘pcre.backtrack_limit’, 999999999);
|
$b = preg_match_all('/(.*?)/',$a ,$c,preg_set_order);
But there are problems with using preg_match to extract target content,
代码如下 |
复制代码 |
ini_set(‘pcre.recursion_limit’, 99999);
|
The code is tested to death.
Later I found that the value of "pcre.backtrack_limit" is only set to 100000 by default.
代码如下 |
复制代码 |
ini_set(‘memory_limit’, ’64M’);
|
Solution: |
The code is as follows |
Copy code |
ini_set(‘pcre.backtrack_limit’, 999999999);
Note: This parameter is available after PHP 5.2.0.
In addition, 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
The code is as follows
|
Copy code
|
ini_set(‘pcre.recursion_limit’, 99999);
In actual project applications, it is best to limit the memory:
The code is as follows
|
Copy code
|
ini_set(‘memory_limit’, ’64M’);
http://www.bkjia.com/PHPjc/632152.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632152.htmlTechArticlepreg_match There will be some problems in the regular matching string. Let me introduce to you how to solve the long characters. Solution to the wrong view when stringing. Example preg_match_all regular...
|
|
|