English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Tutorial Básico PHP

Tutorial Avançado PHP

PHP & MySQL

Manual de Referência PHP

Uso e exemplo da função PHP preg_last_error()

PHP Expressão Regular (PCRE)

A função preg_last_error é usada para retornar o código de erro do último PCRE regular executado.

Sintaxe

int preg_last_error ( void )

Exemplo online

<?php
preg_match('/(?:\D+|<\d+>)*[!?]/', 'foobar foobar foobar');
if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) {
    print 'O limite de backtracking foi esgotado!';
}
?>

O resultado da execução é mostrado a seguir:

O limite de backtracking foi esgotado!

Valor de retorno

  • PREG_NO_ERROR
  • PREG_INTERNAL_ERROR
  • PREG_BACKTRACK_LIMIT_ERROR
  • PREG_RECURSION_LIMIT_ERROR
  • PREG_BAD_UTF8_ERROR
  • PREG_BAD_UTF8_OFFSET_ERROR

Detalhes dos parâmetros podem ser consultados em:PHP Expressão Regular (PCRE)

PHP Expressão Regular (PCRE)