preg_last_error

(PHP 5 >= 5.2.0, PHP 7)

preg_last_error锟斤拷锟斤拷锟斤拷锟揭伙拷锟絇CRE锟斤拷锟斤拷执锟叫诧拷锟斤拷锟侥达拷锟斤拷锟斤拷锟�

说锟斤拷

preg_last_error ( void ) : int

锟斤拷锟斤拷锟斤拷锟揭伙拷锟絇CRE锟斤拷锟斤拷执锟叫的达拷锟斤拷锟斤拷搿�

Example #1 preg_last_error() 示锟斤拷

<?php

preg_match
('/(?:\D+|<\d+>)*[!?]/''foobar foobar foobar');

if (
preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) {
    print 
'Backtrack limit was exhausted!';
}

?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

Backtrack limit was exhausted!

锟斤拷锟斤拷值

锟斤拷锟斤拷锟斤拷锟芥常锟斤拷锟叫碉拷一锟斤拷(锟介看锟斤拷锟斤拷锟斤拷锟斤拷慕锟斤拷锟�):

  • PREG_NO_ERROR
  • PREG_INTERNAL_ERROR
  • PREG_BACKTRACK_LIMIT_ERROR 锟斤拷锟轿硷拷 pcre.backtrack_limit锟斤拷
  • PREG_RECURSION_LIMIT_ERROR 锟斤拷锟轿硷拷 pcre.recursion_limit锟斤拷
  • PREG_BAD_UTF8_ERROR
  • PREG_BAD_UTF8_OFFSET_ERROR 锟斤拷锟斤拷 PHP 5.3.0 锟斤拷
  • PREG_JIT_STACKLIMIT_ERROR (锟斤拷 PHP 7.0.0 锟斤拷)