English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The preg_last_error function is used to return the error code of the last PCRE regular expression execution.
int preg_last_error(void)
<?php
preg_match('/(?:\D+|<\d+>)*[!?]/', 'foobar foobar foobar');
if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) {
print 'The backtrack limit was exhausted!';
}
?>
The execution result is as follows:
The backtrack limit was exhausted!
Detailed parameter descriptions can be viewed at:PHP Regular Expression (PCRE)