3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('MAX_LOOPS',6); function withRefValue($elements, $transform) { echo "\n---( Array with $elements element(s): )---\n"; //Build array: for ($i=0; $i<$elements; $i++) { $a[] = "v.$i"; } $counter=0; echo "--> State of array before loop:\n"; var_dump($a); echo "--> Do loop:\n"; foreach ($a as $k=>&$v) { echo " iteration $counter: \$k=$k; \$v=$v\n"; eval($transform); $counter++; if ($counter>MAX_LOOPS) { echo " ** Stuck in a loop! **\n"; break; } } echo "--> State of array after loop:\n"; var_dump($a); } echo "\nPopping elements off end of an unreferenced array, using &\$value."; $transform = 'array_pop($a);'; withRefValue(1, $transform); withRefValue(2, $transform); withRefValue(3, $transform); withRefValue(4, $transform); withRefValue(5, $transform);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PegUs
function name:  (null)
number of ops:  27
compiled vars:  !0 = $transform
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'MAX_LOOPS'
          2        SEND_VAL                                                 6
          3        DO_ICALL                                                 
   31     4        ECHO                                                     '%0APopping+elements+off+end+of+an+unreferenced+array%2C+using+%26%24value.'
   32     5        ASSIGN                                                   !0, 'array_pop%28%24a%29%3B'
   33     6        INIT_FCALL                                               'withrefvalue'
          7        SEND_VAL                                                 1
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0          
   34    10        INIT_FCALL                                               'withrefvalue'
         11        SEND_VAL                                                 2
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0          
   35    14        INIT_FCALL                                               'withrefvalue'
         15        SEND_VAL                                                 3
         16        SEND_VAR                                                 !0
         17        DO_FCALL                                      0          
   36    18        INIT_FCALL                                               'withrefvalue'
         19        SEND_VAL                                                 4
         20        SEND_VAR                                                 !0
         21        DO_FCALL                                      0          
   37    22        INIT_FCALL                                               'withrefvalue'
         23        SEND_VAL                                                 5
         24        SEND_VAR                                                 !0
         25        DO_FCALL                                      0          
         26      > RETURN                                                   1

Function withrefvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 8
Branch analysis from position: 15
2 jumps found. (Code = 125) Position 1 = 22, Position 2 = 40
Branch analysis from position: 22
2 jumps found. (Code = 126) Position 1 = 23, Position 2 = 40
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 40
Branch analysis from position: 40
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 8
Branch analysis from position: 15
Branch analysis from position: 8
filename:       /in/PegUs
function name:  withRefValue
number of ops:  46
compiled vars:  !0 = $elements, !1 = $transform, !2 = $i, !3 = $a, !4 = $counter, !5 = $v, !6 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        ROPE_INIT                                     3  ~8      '%0A---%28+Array+with+'
          3        ROPE_ADD                                      1  ~8      ~8, !0
          4        ROPE_END                                      2  ~7      ~8, '+element%28s%29%3A+%29---%0A'
          5        ECHO                                                     ~7
    8     6        ASSIGN                                                   !2, 0
          7      > JMP                                                      ->13
    9     8    >   NOP                                                      
          9        FAST_CONCAT                                      ~12     'v.', !2
         10        ASSIGN_DIM                                               !3
         11        OP_DATA                                                  ~12
    8    12        PRE_INC                                                  !2
         13    >   IS_SMALLER                                               !2, !0
         14      > JMPNZ                                                    ~14, ->8
   11    15    >   ASSIGN                                                   !4, 0
   13    16        ECHO                                                     '--%3E+State+of+array+before+loop%3A%0A'
   14    17        INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                                 
   16    20        ECHO                                                     '--%3E+Do+loop%3A%0A'
   17    21      > FE_RESET_RW                                      $17     !3, ->40
         22    > > FE_FETCH_RW                                      ~18     $17, !5, ->40
         23    >   ASSIGN                                                   !6, ~18
   18    24        ROPE_INIT                                     7  ~21     '+++++iteration+'
         25        ROPE_ADD                                      1  ~21     ~21, !4
         26        ROPE_ADD                                      2  ~21     ~21, '%3A++%24k%3D'
         27        ROPE_ADD                                      3  ~21     ~21, !6
         28        ROPE_ADD                                      4  ~21     ~21, '%3B+%24v%3D'
         29        ROPE_ADD                                      5  ~21     ~21, !5
         30        ROPE_END                                      6  ~20     ~21, '%0A'
         31        ECHO                                                     ~20
   19    32        INCLUDE_OR_EVAL                                          !1, EVAL
   20    33        PRE_INC                                                  !4
   21    34        FETCH_CONSTANT                                   ~27     'MAX_LOOPS'
         35        IS_SMALLER                                               ~27, !4
         36      > JMPZ                                                     ~28, ->39
   22    37    >   ECHO                                                     '++%2A%2A+Stuck+in+a+loop%21+%2A%2A%0A'
   23    38      > JMP                                                      ->40
   17    39    > > JMP                                                      ->22
         40    >   FE_FREE                                                  $17
   27    41        ECHO                                                     '--%3E+State+of+array+after+loop%3A%0A'
   28    42        INIT_FCALL                                               'var_dump'
         43        SEND_VAR                                                 !3
         44        DO_ICALL                                                 
   29    45      > RETURN                                                   null

End of function withrefvalue

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.72 ms | 1403 KiB | 22 Q