3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getMiddle($text) { $length = strlen($text); // if even: if ($length%2 == 0) { return substr($text, $length/2, 2); } // if odd: else { return substr($text, $length/2, 1); } } echo getMiddle('test');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bO3Zr
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'getmiddle'
          1        SEND_VAL                                                 'test'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function getmiddle:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bO3Zr
function name:  getMiddle
number of ops:  22
compiled vars:  !0 = $text, !1 = $length
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        STRLEN                                           ~2      !0
          2        ASSIGN                                                   !1, ~2
    6     3        MOD                                              ~4      !1, 2
          4        IS_EQUAL                                                 ~4, 0
          5      > JMPZ                                                     ~5, ->14
    7     6    >   INIT_FCALL                                               'substr'
          7        SEND_VAR                                                 !0
          8        DIV                                              ~6      !1, 2
          9        SEND_VAL                                                 ~6
         10        SEND_VAL                                                 2
         11        DO_ICALL                                         $7      
         12      > RETURN                                                   $7
         13*       JMP                                                      ->21
   11    14    >   INIT_FCALL                                               'substr'
         15        SEND_VAR                                                 !0
         16        DIV                                              ~8      !1, 2
         17        SEND_VAL                                                 ~8
         18        SEND_VAL                                                 1
         19        DO_ICALL                                         $9      
         20      > RETURN                                                   $9
   13    21*     > RETURN                                                   null

End of function getmiddle

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.8 ms | 1398 KiB | 16 Q