3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* How many times the code under test should run in each function */ define('LOOP', 10); define('MAX', 10); function f1() { for ($i = 0; $i < LOOP; ++$i) { // one liner array_map with anonymous function - 5.3+ return $array = array_map(function($d) { return 'count_' . $d; }, range(0, MAX)); } } function f2() { for ($i = 0; $i < LOOP; ++$i) { // another (convoluted) one line approach, avoiding array_map - 5.2+ return $array = explode('#', 'count_' . implode('#count_', range(0, MAX))); } } echo f1();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c6sN9
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'LOOP'
          2        SEND_VAL                                                 10
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'define'
          5        SEND_VAL                                                 'MAX'
          6        SEND_VAL                                                 10
          7        DO_ICALL                                                 
   27     8        INIT_FCALL                                               'f1'
          9        DO_FCALL                                      0  $2      
         10        ECHO                                                     $2
         11      > RETURN                                                   1

Function f1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c6sN9
function name:  f1
number of ops:  19
compiled vars:  !0 = $i, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->15
   10     2    >   INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fc6sN9%3A10%240'
          4        SEND_VAL                                                 ~3
          5        INIT_FCALL                                               'range'
          6        SEND_VAL                                                 0
          7        FETCH_CONSTANT                                   ~4      'MAX'
          8        SEND_VAL                                                 ~4
          9        DO_ICALL                                         $5      
         10        SEND_VAR                                                 $5
         11        DO_ICALL                                         $6      
         12        ASSIGN                                           ~7      !1, $6
         13      > RETURN                                                   ~7
    8    14*       PRE_INC                                                  !0
         15    >   FETCH_CONSTANT                                   ~9      'LOOP'
         16        IS_SMALLER                                               !0, ~9
         17      > JMPNZ                                                    ~10, ->2
   12    18    > > RETURN                                                   null

End of function f1

Function %00%7Bclosure%7D%2Fin%2Fc6sN9%3A10%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c6sN9
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        CONCAT                                           ~1      'count_', !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fc6sN9%3A10%240

Function f2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c6sN9
function name:  f2
number of ops:  23
compiled vars:  !0 = $i, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->19
   17     2    >   INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%23'
          4        INIT_FCALL                                               'implode'
          5        SEND_VAL                                                 '%23count_'
          6        INIT_FCALL                                               'range'
          7        SEND_VAL                                                 0
          8        FETCH_CONSTANT                                   ~3      'MAX'
          9        SEND_VAL                                                 ~3
         10        DO_ICALL                                         $4      
         11        SEND_VAR                                                 $4
         12        DO_ICALL                                         $5      
         13        CONCAT                                           ~6      'count_', $5
         14        SEND_VAL                                                 ~6
         15        DO_ICALL                                         $7      
         16        ASSIGN                                           ~8      !1, $7
         17      > RETURN                                                   ~8
   15    18*       PRE_INC                                                  !0
         19    >   FETCH_CONSTANT                                   ~10     'LOOP'
         20        IS_SMALLER                                               !0, ~10
         21      > JMPNZ                                                    ~11, ->2
   19    22    > > RETURN                                                   null

End of function f2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.67 ms | 1402 KiB | 24 Q