3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getNumber() { echo 'im getting called!' . PHP_EOL; return rand(0,10); } // getNumber gets called on every loop for ($i = 0; $i <= getNumber(); $i++) { echo 'loop' . PHP_EOL; } echo PHP_EOL . '---' . PHP_EOL . PHP_EOL; // getNumber gets called only once for ($i = getNumber(); $i > 0 ; $i--) { echo 'loop' . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 2
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 13
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 13
Branch analysis from position: 17
Branch analysis from position: 13
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 2
Branch analysis from position: 8
Branch analysis from position: 2
filename:       /in/d1AIP
function name:  (null)
number of ops:  18
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->4
   11     2    >   ECHO                                                     'loop%0A'
   10     3        PRE_INC                                                  !0
          4    >   INIT_FCALL                                               'getnumber'
          5        DO_FCALL                                      0  $3      
          6        IS_SMALLER_OR_EQUAL                                      !0, $3
          7      > JMPNZ                                                    ~4, ->2
   14     8    >   ECHO                                                     '%0A---%0A%0A'
   17     9        INIT_FCALL                                               'getnumber'
         10        DO_FCALL                                      0  $5      
         11        ASSIGN                                                   !0, $5
         12      > JMP                                                      ->15
   18    13    >   ECHO                                                     'loop%0A'
   17    14        PRE_DEC                                                  !0
         15    >   IS_SMALLER                                               0, !0
         16      > JMPNZ                                                    ~8, ->13
   19    17    > > RETURN                                                   1

Function getnumber:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d1AIP
function name:  getNumber
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ECHO                                                     'im+getting+called%21%0A'
    6     1        INIT_FCALL                                               'rand'
          2        SEND_VAL                                                 0
          3        SEND_VAL                                                 10
          4        DO_ICALL                                         $0      
          5      > RETURN                                                   $0
    7     6*     > RETURN                                                   null

End of function getnumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.71 ms | 1008 KiB | 16 Q