3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '0123456789'; $maxLength = 5; if(($maxLength > 0) && (strlen($string) > $maxLength)) { if(function_exists('mb_check_encoding') && @mb_check_encoding($string, 'UTF-8') && function_exists('mb_substr')) { while(strlen($string) > $maxLength) { $string = mb_substr($string, 0, -1, 'UTF-8'); } } else { $string = rtrim(substr($string, 0, $maxLength)); } } echo $string;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 46
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 37
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 26
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 26
Branch analysis from position: 36
Branch analysis from position: 26
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 19
Branch analysis from position: 46
Branch analysis from position: 7
filename:       /in/N81Ql
function name:  (null)
number of ops:  48
compiled vars:  !0 = $string, !1 = $maxLength
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '0123456789'
    3     1        ASSIGN                                                   !1, 5
    4     2        IS_SMALLER                                       ~4      0, !1
          3      > JMPZ_EX                                          ~4      ~4, ->7
          4    >   STRLEN                                           ~5      !0
          5        IS_SMALLER                                       ~6      !1, ~5
          6        BOOL                                             ~4      ~6
          7    > > JMPZ                                                     ~4, ->46
    6     8    >   INIT_FCALL                                               'function_exists'
          9        SEND_VAL                                                 'mb_check_encoding'
         10        DO_ICALL                                         $7      
         11      > JMPZ_EX                                          ~8      $7, ->19
         12    >   BEGIN_SILENCE                                    ~9      
         13        INIT_FCALL                                               'mb_check_encoding'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 'UTF-8'
         16        DO_ICALL                                         $10     
         17        END_SILENCE                                              ~9
         18        BOOL                                             ~8      $10
         19    > > JMPZ_EX                                          ~8      ~8, ->24
         20    >   INIT_FCALL                                               'function_exists'
         21        SEND_VAL                                                 'mb_substr'
         22        DO_ICALL                                         $11     
         23        BOOL                                             ~8      $11
         24    > > JMPZ                                                     ~8, ->37
    8    25    > > JMP                                                      ->33
   10    26    >   INIT_FCALL                                               'mb_substr'
         27        SEND_VAR                                                 !0
         28        SEND_VAL                                                 0
         29        SEND_VAL                                                 -1
         30        SEND_VAL                                                 'UTF-8'
         31        DO_ICALL                                         $12     
         32        ASSIGN                                                   !0, $12
    8    33    >   STRLEN                                           ~14     !0
         34        IS_SMALLER                                               !1, ~14
         35      > JMPNZ                                                    ~15, ->26
         36    > > JMP                                                      ->46
   14    37    >   INIT_FCALL                                               'rtrim'
         38        INIT_FCALL                                               'substr'
         39        SEND_VAR                                                 !0
         40        SEND_VAL                                                 0
         41        SEND_VAR                                                 !1
         42        DO_ICALL                                         $16     
         43        SEND_VAR                                                 $16
         44        DO_ICALL                                         $17     
         45        ASSIGN                                                   !0, $17
   17    46    >   ECHO                                                     !0
         47      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.13 ms | 1400 KiB | 23 Q