array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'function.preg-last-error.php', 1 => 'preg_last_error', ), 'up' => array ( 0 => 'ref.pcre.php', 1 => 'Funções da 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' => 'pt_BR', '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 — Retorna o código de erro da última expressão regular PCRE executada
Retorna o código de erro da última expressão regular PCRE executada.
Exemplo #1 Exemplo de preg_last_error()
<?php
preg_match('/(?:\D+|<\d+>)*[!?]/', 'foobar foobar foobar');
if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) {
echo 'Backtrack limit was exhausted!';
}
?>
O exemplo acima produzirá:
Backtrack limit was exhausted!
Esta função não possui parâmetros.
Retorna uma das seguintes constantes (explicadas em sua própria página):