preg_last_error()

preg_last_error() — Returns the error code of the last PCRE regex execution.

Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.2.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

preg_last_error(): int

Parameters

This function takes no parameters.

Return value

Returns one of the following constants (explained on their own page): PREG_NO_ERROR PREG_INTERNAL_ERROR PREG_BACKTRACK_LIMIT_ERROR (see also pcre.backtrack_limit) PREG_RECURSION_LIMIT_ERROR (see also pcre.recursion_limit) PREG_BAD_UTF8_ERROR PREG_BAD_UTF8_OFFSET_ERROR PREG_JIT_STACKLIMIT_ERROR

Example

The PHP manual ships no example for preg_last_error(); the signature and the parameter table above are the contract.

See also

preg_last_error_msg()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page preg_last_error() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.