3v4l.org

run code in 500+ PHP versions simultaneously
<?php $input = '🧪 test'; $encodings = ['utf-8', 'utf-16', 'utf-32']; foreach ($encodings as $to) { var_dump([ 'to' => $to, 'mb_substr' => mb_substr($input, 3, 4, $to), 'iconv_substr' => iconv_substr($input, 3, 4, $to), 'substr' => substr($input, 3, 4), 'substr+utf8_encode' => substr(utf8_encode($input), 3, 4), 'substr+utf8_decode' => substr(utf8_decode($input), 3, 4) ]); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 38
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 38
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/I3lr4
function name:  (null)
number of ops:  40
compiled vars:  !0 = $input, !1 = $encodings, !2 = $to
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%F0%9F%A7%AA+test'
    5     1        ASSIGN                                                       !1, <array>
    7     2      > FE_RESET_R                                           $5      !1, ->38
          3    > > FE_FETCH_R                                                   $5, !2, ->38
    8     4    >   INIT_FCALL                                                   'var_dump'
    9     5        INIT_ARRAY                                           ~6      !2, 'to'
   10     6        INIT_FCALL                                                   'mb_substr'
          7        SEND_VAR                                                     !0
          8        SEND_VAL                                                     3
          9        SEND_VAL                                                     4
         10        SEND_VAR                                                     !2
         11        DO_ICALL                                             $7      
         12        ADD_ARRAY_ELEMENT                                    ~6      $7, 'mb_substr'
   11    13        INIT_FCALL_BY_NAME                                           'iconv_substr'
         14        SEND_VAR_EX                                                  !0
         15        SEND_VAL_EX                                                  3
         16        SEND_VAL_EX                                                  4
         17        SEND_VAR_EX                                                  !2
         18        DO_FCALL                                          0  $8      
         19        ADD_ARRAY_ELEMENT                                    ~6      $8, 'iconv_substr'
   12    20        FRAMELESS_ICALL_3                substr              ~9      !0, 3
         21        OP_DATA                                                      4
         22        ADD_ARRAY_ELEMENT                                    ~6      ~9, 'substr'
   13    23        INIT_FCALL                                                   'utf8_encode'
         24        SEND_VAR                                                     !0
         25        DO_FCALL_BY_NAME                                             
         26        FRAMELESS_ICALL_3                substr              ~11     $10, 3
         27        OP_DATA                                                      4
         28        ADD_ARRAY_ELEMENT                                    ~6      ~11, 'substr%2Butf8_encode'
   14    29        INIT_FCALL                                                   'utf8_decode'
         30        SEND_VAR                                                     !0
         31        DO_FCALL_BY_NAME                                             
         32        FRAMELESS_ICALL_3                substr              ~13     $12, 3
         33        OP_DATA                                                      4
         34        ADD_ARRAY_ELEMENT                                    ~6      ~13, 'substr%2Butf8_decode'
         35        SEND_VAL                                                     ~6
    8    36        DO_ICALL                                                     
    7    37      > JMP                                                          ->3
         38    >   FE_FREE                                                      $5
   16    39      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
219.34 ms | 2282 KiB | 17 Q