array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.preg-last-error.php', 1 => 'preg_last_error', ), 'up' => array ( 0 => 'ref.pcre.php', 1 => 'PCRE 函数', ), 'prev' => array ( 0 => 'function.preg-last-error-msg.php', 1 => 'preg_last_error_msg', ), 'next' => array ( 0 => 'function.preg-match-all.php', 1 => 'preg_match_all', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/pcre/functions/preg-last-error.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
preg_last_error — 返回最后一个PCRE正则执行产生的错误代码
返回最后一次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!
此函数没有参数。
返回下面常量中的一个(查看它们自身的解释):