3v4l.org

run code in 300+ PHP versions simultaneously
<?php function cn_substrr($str,$slen,$startdd=0) { $str = cn_substr(stripslashes($str),$slen,$startdd); return addslashes($str); } function cn_substr($str,$slen,$startdd=0) { global $cfg_soft_lang; if($cfg_soft_lang=='utf-8') { return cn_substr_utf8($str,$slen,$startdd); } $restr = ''; $c = ''; $str_len = strlen($str); if($str_len < $startdd+1) { return ''; } if($str_len < $startdd + $slen || $slen==0) { $slen = $str_len - $startdd; } $enddd = $startdd + $slen - 1; for($i=0;$i<$str_len;$i++) { if($startdd==0) { $restr .= $c; } else if($i > $startdd) { $restr .= $c; } if(ord($str[$i])>0x80) { if($str_len>$i+1) { $c = $str[$i].$str[$i+1]; } $i++; } else { $c = $str[$i]; } if($i >= $enddd) { if(strlen($restr)+strlen($c)>$slen) { break; } else { $restr .= $c; break; } } } return $restr; } $a = '测试这是一个测试'; //$a = 'xxxxbbbbbnnn'; $b = cn_substrr($a,5,0); var_dump($b); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gFHWe
function name:  (null)
number of ops:  11
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     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'
   71     1        INIT_FCALL                                               'cn_substrr'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 5
          4        SEND_VAL                                                 0
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !1, $3
   72     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
   74    10      > RETURN                                                   1

Function cn_substrr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gFHWe
function name:  cn_substrr
number of ops:  17
compiled vars:  !0 = $str, !1 = $slen, !2 = $startdd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      0
    5     3        INIT_FCALL_BY_NAME                                       'cn_substr'
          4        INIT_FCALL                                               'stripslashes'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        SEND_VAR_NO_REF_EX                                       $3
          8        SEND_VAR_EX                                              !1
          9        SEND_VAR_EX                                              !2
         10        DO_FCALL                                      0  $4      
         11        ASSIGN                                                   !0, $4
    6    12        INIT_FCALL                                               'addslashes'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $6      
         15      > RETURN                                                   $6
    7    16*     > RETURN                                                   null

End of function cn_substrr

Function cn_substr:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 47) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 33
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 37
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 56
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 54
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 69
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 67
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 69
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 33
Branch analysis from position: 72
Branch analysis from position: 33
Branch analysis from position: 54
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 69
Branch analysis from position: 60
Branch analysis from position: 69
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 40
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 56
Branch analysis from position: 46
Branch analysis from position: 56
Branch analysis from position: 40
Branch analysis from position: 28
Branch analysis from position: 25
filename:       /in/gFHWe
function name:  cn_substr
number of ops:  74
compiled vars:  !0 = $str, !1 = $slen, !2 = $startdd, !3 = $cfg_soft_lang, !4 = $restr, !5 = $c, !6 = $str_len, !7 = $enddd, !8 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      0
   10     3        BIND_GLOBAL                                              !3, 'cfg_soft_lang'
   11     4        IS_EQUAL                                                 !3, 'utf-8'
          5      > JMPZ                                                     ~9, ->12
   13     6    >   INIT_FCALL_BY_NAME                                       'cn_substr_utf8'
          7        SEND_VAR_EX                                              !0
          8        SEND_VAR_EX                                              !1
          9        SEND_VAR_EX                                              !2
         10        DO_FCALL                                      0  $10     
         11      > RETURN                                                   $10
   15    12    >   ASSIGN                                                   !4, ''
   16    13        ASSIGN                                                   !5, ''
   17    14        STRLEN                                           ~13     !0
         15        ASSIGN                                                   !6, ~13
   18    16        ADD                                              ~15     !2, 1
         17        IS_SMALLER                                               !6, ~15
         18      > JMPZ                                                     ~16, ->20
   20    19    > > RETURN                                                   ''
   22    20    >   ADD                                              ~17     !2, !1
         21        IS_SMALLER                                       ~18     !6, ~17
         22      > JMPNZ_EX                                         ~18     ~18, ->25
         23    >   IS_EQUAL                                         ~19     !1, 0
         24        BOOL                                             ~18     ~19
         25    > > JMPZ                                                     ~18, ->28
   24    26    >   SUB                                              ~20     !6, !2
         27        ASSIGN                                                   !1, ~20
   26    28    >   ADD                                              ~22     !2, !1
         29        SUB                                              ~23     ~22, 1
         30        ASSIGN                                                   !7, ~23
   27    31        ASSIGN                                                   !8, 0
         32      > JMP                                                      ->70
   29    33    >   IS_EQUAL                                                 !2, 0
         34      > JMPZ                                                     ~26, ->37
   31    35    >   ASSIGN_OP                                     8          !4, !5
         36      > JMP                                                      ->40
   33    37    >   IS_SMALLER                                               !2, !8
         38      > JMPZ                                                     ~28, ->40
   35    39    >   ASSIGN_OP                                     8          !4, !5
   37    40    >   INIT_FCALL                                               'ord'
         41        FETCH_DIM_R                                      ~30     !0, !8
         42        SEND_VAL                                                 ~30
         43        DO_ICALL                                         $31     
         44        IS_SMALLER                                               128, $31
         45      > JMPZ                                                     ~32, ->56
   39    46    >   ADD                                              ~33     !8, 1
         47        IS_SMALLER                                               ~33, !6
         48      > JMPZ                                                     ~34, ->54
   41    49    >   FETCH_DIM_R                                      ~35     !0, !8
         50        ADD                                              ~36     !8, 1
         51        FETCH_DIM_R                                      ~37     !0, ~36
         52        CONCAT                                           ~38     ~35, ~37
         53        ASSIGN                                                   !5, ~38
   43    54    >   PRE_INC                                                  !8
         55      > JMP                                                      ->58
   47    56    >   FETCH_DIM_R                                      ~41     !0, !8
         57        ASSIGN                                                   !5, ~41
   49    58    >   IS_SMALLER_OR_EQUAL                                      !7, !8
         59      > JMPZ                                                     ~43, ->69
   51    60    >   STRLEN                                           ~44     !4
         61        STRLEN                                           ~45     !5
         62        ADD                                              ~46     ~44, ~45
         63        IS_SMALLER                                               !1, ~46
         64      > JMPZ                                                     ~47, ->67
   53    65    > > JMP                                                      ->72
         66*       JMP                                                      ->69
   57    67    >   ASSIGN_OP                                     8          !4, !5
   58    68      > JMP                                                      ->72
   27    69    >   PRE_INC                                                  !8
         70    >   IS_SMALLER                                               !8, !6
         71      > JMPNZ                                                    ~50, ->33
   62    72    > > RETURN                                                   !4
   63    73*     > RETURN                                                   null

End of function cn_substr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.23 ms | 1407 KiB | 22 Q