PHP 8.4.2 Released!

Попередньо визначені константи

Константи, описані нижче — визначені цим розширенням, тож доступні, коли розширення скомпільовано як частина PHP або динамічно підключене під час виконання.

PREG constants
Константи Опис As of
PREG_PATTERN_ORDER (int) Orders results so that $matches[0] is an array of full pattern matches, $matches[1] is an array of strings matched by the first parenthesized subpattern, and so on. This flag is only used with preg_match_all().  
PREG_SET_ORDER (int) Orders results so that $matches[0] is an array of first set of matches, $matches[1] is an array of second set of matches, and so on. This flag is only used with preg_match_all().  
PREG_OFFSET_CAPTURE (int) See the description of PREG_SPLIT_OFFSET_CAPTURE.  
PREG_SPLIT_NO_EMPTY (int) This flag tells preg_split() to return only non-empty pieces.  
PREG_SPLIT_DELIM_CAPTURE (int) This flag tells preg_split() to capture parenthesized expression in the delimiter pattern as well.  
PREG_SPLIT_OFFSET_CAPTURE (int) If this flag is set, for every occurring match the appendant string offset will also be returned. Note that this changes the return values in an array where every element is an array consisting of the matched string at offset 0 and its string offset within subject at offset 1. This flag is only used for preg_split().  
PREG_UNMATCHED_AS_NULL (int) This flag tells preg_match() and preg_match_all() to include unmatched subpatterns in $matches as null values. Without this flag, unmatched subpatterns are reported as empty strings, as if they were empty matches. Setting this flag allows to distinguish between these two cases. 7.2.0
PREG_NO_ERROR (int) Returned by preg_last_error() if there were no errors. 5.2.0
PREG_INTERNAL_ERROR (int) Returned by preg_last_error() if there was an internal PCRE error. 5.2.0
PREG_BACKTRACK_LIMIT_ERROR (int) Returned by preg_last_error() if backtrack limit was exhausted. 5.2.0
PREG_RECURSION_LIMIT_ERROR (int) Returned by preg_last_error() if recursion limit was exhausted. 5.2.0
PREG_BAD_UTF8_ERROR (int) Returned by preg_last_error() if the last error was caused by malformed UTF-8 data (only when running a regex in UTF-8 mode). 5.2.0
PREG_BAD_UTF8_OFFSET_ERROR (int) Returned by preg_last_error() if the offset didn't correspond to the begin of a valid UTF-8 code point (only when running a regex in UTF-8 mode). 5.3.0
PREG_JIT_STACKLIMIT_ERROR (int) Returned by preg_last_error() if the last PCRE function failed due to limited JIT stack space. 7.0.0
PCRE_VERSION (string) PCRE version and release date (e.g. "7.0 18-Dec-2006"). 5.2.4
PCRE_VERSION_MAJOR (int) PCRE major version number.  
PCRE_VERSION_MINOR (int) PCRE minor version number.  
PCRE_JIT_SUPPORT (bool) Indicates whether PCRE JIT support is available.  
PREG_GREP_INVERT (int) Return the elements that do not match a given pattern.  
add a note

User Contributed Notes 2 notes

up
27
erutan409 at hotmail dot com
9 years ago
PREG_PATTERN_ORDER: 1
PREG_SET_ORDER: 2
PREG_OFFSET_CAPTURE: 256
PREG_SPLIT_NO_EMPTY: 1
PREG_SPLIT_DELIM_CAPTURE: 2
PREG_SPLIT_OFFSET_CAPTURE: 4
PREG_NO_ERROR: 0
PREG_INTERNAL_ERROR: 1
PREG_BACKTRACK_LIMIT_ERROR: 2
PREG_RECURSION_LIMIT_ERROR: 3
PREG_BAD_UTF8_ERROR: 4
PREG_BAD_UTF8_OFFSET_ERROR: 5
PCRE_VERSION: %YOUR_VERSION_NUMBER%
up
16
Robert
8 years ago
The new PREG_JIT_STACKLIMIT_ERROR constant introduced with PHP 7.0.0 has got a value of 6.

I experienced this error code when parsing a 112KB file. preg_match_all failed with this error. Interesting was: The matches array contained some entries, but not all as the command failed (I missed to check the return value).

Unfortunately you can not configure the stack-size of the PCRE JIT. The only way out was - at least for me - to disable the PCRE JIT via php.ini (pcre.jit=0).
To Top