Skip to content

Instantly share code, notes, and snippets.

@mdyn
Forked from anonymous/RegExp_error_check.php
Created December 18, 2012 10:34
Show Gist options
  • Save mdyn/4326968 to your computer and use it in GitHub Desktop.
Save mdyn/4326968 to your computer and use it in GitHub Desktop.
<?php
switch( preg_last_error() ){
case PREG_NO_ERROR :
$preg_error = 'No error';
break;
case PREG_INTERNAL_ERROR :
$preg_error = 'An internal PCRE error';
break;
case PREG_BACKTRACK_LIMIT_ERROR :
$preg_error = 'Backtrack limit was exhausted';
break;
case PREG_RECURSION_LIMIT_ERROR :
$preg_error = 'Recursion limit was exhausted';
break;
case PREG_BAD_UTF8_ERROR :
$preg_error = 'Malformed UTF-8 data';
break;
case PREG_BAD_UTF8_OFFSET_ERROR :
$preg_error = 'Offset didn\'t correspond to the begin of a valid UTF-8 code point';
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment