3v4l.org

run code in 300+ PHP versions simultaneously
<?php function msubstr($str, $start, $len) { $tmpstr = ""; $strlen = $start + $len; for($i = 0; $i < $strlen; $i++) { if(ord(substr($str, $i, 1)) > 0xa0) { $tmpstr .= substr($str, $i, 2); $i++; } else $tmpstr .= substr($str, $i, 1); } return $tmpstr; } var_dump(); // $a = '测试这是一个测试'; $a = 'xxxxbbbbbnnn'; $b = msubstr($a,0,5); var_dump($b); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/phjiA
function name:  (null)
number of ops:  14
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'var_dump'
          1        DO_ICALL                                                 
   19     2        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'
   20     3        ASSIGN                                                   !0, 'xxxxbbbbbnnn'
   22     4        INIT_FCALL                                               'msubstr'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 0
          7        SEND_VAL                                                 5
          8        DO_FCALL                                      0  $5      
          9        ASSIGN                                                   !1, $5
   23    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
   25    13      > RETURN                                                   1

Function msubstr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 8
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 26
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 8
Branch analysis from position: 35
Branch analysis from position: 8
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 8
Branch analysis from position: 35
Branch analysis from position: 8
filename:       /in/phjiA
function name:  msubstr
number of ops:  37
compiled vars:  !0 = $str, !1 = $start, !2 = $len, !3 = $tmpstr, !4 = $strlen, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    3     3        ASSIGN                                                   !3, ''
    4     4        ADD                                              ~7      !1, !2
          5        ASSIGN                                                   !4, ~7
    5     6        ASSIGN                                                   !5, 0
          7      > JMP                                                      ->33
    6     8    >   INIT_FCALL                                               'ord'
          9        INIT_FCALL                                               'substr'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !5
         12        SEND_VAL                                                 1
         13        DO_ICALL                                         $10     
         14        SEND_VAR                                                 $10
         15        DO_ICALL                                         $11     
         16        IS_SMALLER                                               160, $11
         17      > JMPZ                                                     ~12, ->26
    7    18    >   INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !0
         20        SEND_VAR                                                 !5
         21        SEND_VAL                                                 2
         22        DO_ICALL                                         $13     
         23        ASSIGN_OP                                     8          !3, $13
    8    24        PRE_INC                                                  !5
         25      > JMP                                                      ->32
   10    26    >   INIT_FCALL                                               'substr'
         27        SEND_VAR                                                 !0
         28        SEND_VAR                                                 !5
         29        SEND_VAL                                                 1
         30        DO_ICALL                                         $16     
         31        ASSIGN_OP                                     8          !3, $16
    5    32    >   PRE_INC                                                  !5
         33    >   IS_SMALLER                                               !5, !4
         34      > JMPNZ                                                    ~19, ->8
   12    35    > > RETURN                                                   !3
   13    36*     > RETURN                                                   null

End of function msubstr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.83 ms | 1403 KiB | 20 Q