preg_last_error

Supported Versions: PHP 5 >= 5.2.0, PHP 7, PHP 8
Returns the error code of the last PCRE regex execution
<?php preg_last_error(): int