3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_utf8($string) { if (strlen($string) == 0) { return true; } return preg_match('%^(?: [\x09\x0A\x0D\x20-\x7E] # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )*$%xs', $string); } $string = "1234567890123456789012345678..."; echo strlen($string); var_dump(is_utf8($string));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/de26d
function name:  (null)
number of ops:  10
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                   !0, '1234567890123456789012345678...'
   22     1        STRLEN                                           ~2      !0
          2        ECHO                                                     ~2
   23     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'is_utf8'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function is_utf8:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/de26d
function name:  is_utf8
number of ops:  11
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        STRLEN                                           ~1      !0
          2        IS_EQUAL                                                 ~1, 0
          3      > JMPZ                                                     ~2, ->5
    6     4    > > RETURN                                                   <true>
    9     5    >   INIT_FCALL                                               'preg_match'
          6        SEND_VAL                                                 '%25%5E%28%3F%3A%0A++++++++%5B%5Cx09%5Cx0A%5Cx0D%5Cx20-%5Cx7E%5D++++++++++++++%23+ASCII%0A++++++++%7C+%5B%5CxC2-%5CxDF%5D%5B%5Cx80-%5CxBF%5D+++++++++++++%23+non-overlong+2-byte%0A++++++++%7C++%5CxE0%5B%5CxA0-%5CxBF%5D%5B%5Cx80-%5CxBF%5D++++++++%23+excluding+overlongs%0A++++++++%7C+%5B%5CxE1-%5CxEC%5CxEE%5CxEF%5D%5B%5Cx80-%5CxBF%5D%7B2%7D++%23+straight+3-byte%0A++++++++%7C++%5CxED%5B%5Cx80-%5Cx9F%5D%5B%5Cx80-%5CxBF%5D++++++++%23+excluding+surrogates%0A++++++++%7C++%5CxF0%5B%5Cx90-%5CxBF%5D%5B%5Cx80-%5CxBF%5D%7B2%7D+++++%23+planes+1-3%0A++++++++%7C+%5B%5CxF1-%5CxF3%5D%5B%5Cx80-%5CxBF%5D%7B3%7D++++++++++%23+planes+4-15%0A++++++++%7C++%5CxF4%5B%5Cx80-%5Cx8F%5D%5B%5Cx80-%5CxBF%5D%7B2%7D+++++%23+plane+16%0A++++%29%2A%24%25xs'
   18     7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $3      
          9      > RETURN                                                   $3
   19    10*     > RETURN                                                   null

End of function is_utf8

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.95 ms | 1403 KiB | 18 Q