3v4l.org

run code in 300+ PHP versions simultaneously
<?php function cn_substr_utf8($str, $length, $start=0) { { return ''; } preg_match_all("/./su", $str, $ar); $str = ''; $tstr = ''; //为了兼容mysql教程4.1以下版本,与数据库教程varchar一致,这里使用按字节截取 for($i=0; isset($ar[0][$i]); $i++) { if(strlen($tstr) < $start) { $tstr .= $ar[0][$i]; } else { if(strlen($str) < $length + strlen($ar[0][$i]) ) { $str .= $ar[0][$i]; } else { break; } } } return $str; } $a = '测试这是一个测试'; $a = 'xxxxbbbbbnnn'; $b = cn_substr_utf8($a,5,0); var_dump($b); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/arpXO
function name:  (null)
number of ops:  12
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   ASSIGN                                                   !0, '%E6%B5%8B%E8%AF%95%E8%BF%99%E6%98%AF%E4%B8%80%E4%B8%AA%E6%B5%8B%E8%AF%95'
   36     1        ASSIGN                                                   !0, 'xxxxbbbbbnnn'
   38     2        INIT_FCALL                                               'cn_substr_utf8'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 5
          5        SEND_VAL                                                 0
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !1, $4
   39     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   41    11      > RETURN                                                   1

Function cn_substr_utf8:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/arpXO
function name:  cn_substr_utf8
number of ops:  38
compiled vars:  !0 = $str, !1 = $length, !2 = $start, !3 = $ar, !4 = $tstr, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      0
    7     3      > RETURN                                                   ''
    9     4*       INIT_FCALL                                               'preg_match_all'
          5*       SEND_VAL                                                 '%2F.%2Fsu'
          6*       SEND_VAR                                                 !0
          7*       SEND_REF                                                 !3
          8*       DO_ICALL                                                 
   10     9*       ASSIGN                                                   !0, ''
   11    10*       ASSIGN                                                   !4, ''
   13    11*       ASSIGN                                                   !5, 0
         12*       JMP                                                      ->33
   15    13*       STRLEN                                           ~10     !4
         14*       IS_SMALLER                                               ~10, !2
         15*       JMPZ                                                     ~11, ->20
   17    16*       FETCH_DIM_R                                      ~12     !3, 0
         17*       FETCH_DIM_R                                      ~13     ~12, !5
         18*       ASSIGN_OP                                     8          !4, ~13
         19*       JMP                                                      ->32
   21    20*       STRLEN                                           ~15     !0
         21*       FETCH_DIM_R                                      ~16     !3, 0
         22*       FETCH_DIM_R                                      ~17     ~16, !5
         23*       STRLEN                                           ~18     ~17
         24*       ADD                                              ~19     !1, ~18
         25*       IS_SMALLER                                               ~15, ~19
         26*       JMPZ                                                     ~20, ->31
   23    27*       FETCH_DIM_R                                      ~21     !3, 0
         28*       FETCH_DIM_R                                      ~22     ~21, !5
         29*       ASSIGN_OP                                     8          !0, ~22
         30*       JMP                                                      ->32
   27    31*       JMP                                                      ->36
   13    32*       PRE_INC                                                  !5
         33*       FETCH_DIM_IS                                     ~25     !3, 0
         34*       ISSET_ISEMPTY_DIM_OBJ                         0          ~25, !5
         35*       JMPNZ                                                    ~26, ->13
   31    36*       RETURN                                                   !0
   32    37*     > RETURN                                                   null

End of function cn_substr_utf8

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.87 ms | 1403 KiB | 18 Q