Preg in PHP

Source: Internet
Author: User
Tags preg

This article mainly introduces the Preg_match function of PHP in the string length problem, if you also encountered Preg_match is always extracted content is blank or extracted, it may be encountered this problem, the need for friends can refer to the

Project, with Preg_match is to extract the target content, dead and dead have problems, the code measured to death.

Later suspected PHP Preg_match has string length limit, sure enough, found that the value of "Pcre.backtrack_limit" by default only set 100000.

Solution: Ini_set (' Pcre.backtrack_limit ', 999999999);

Note: This parameter is available after PHP version 5.2.0.

In addition to say about: Pcre.recursion_limit

Pcre.recursion_limit is the recursive limit of the pcre, which, if set to a large value, consumes all the available stacks of the process and eventually causes PHP to crash.

can also be limited by modifying the configuration: Ini_set (' Pcre.recursion_limit ', 99999);

In the actual project application, it is best to limit the memory setting: Ini_set (' memory_limit ', ' 64M '); , which is more secure.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.