PHP preg_match matching string length case analysis

php中世界最好的语言
Release: 2023-03-27 08:32:02
Original
1585 people have browsed it

This time I will bring you php preg_match matching string length case analysis, what are the precautions for php preg_match matching string length, the following are Let’s take a look at practical cases.

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);
Copy after login

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);

In actual project applications, it is best to limit the memory: ini_set('memory_limit', '64M '); , which is safer.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese website Other related articles!

Recommended reading:

php Detailed explanation of ZIP compression class example steps

PHP crops without affecting the shape of the image

The above is the detailed content of PHP preg_match matching string length case analysis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template