preg_last_error

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

preg_last_error返回最后一个PCRE正则执行产生的错误代码

说明

preg_last_error(): int

返回最后一次PCRE正则执行的错误代码。

示例 #1 preg_last_error() 示例

<?php

preg_match
('/(?:\D+|<\d+>)*[!?]/', 'foobar foobar foobar');

if (
preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) {
echo
'Backtrack limit was exhausted!';
}

?>

以上示例会输出:

Backtrack limit was exhausted!

参数

此函数没有参数。

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top