3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements IteratorAggregate { private $data = [ 'foo' => 'bar', 'bar' => 'baz' ]; public function getIterator() { return new ArrayIterator($this->data); } } $Foo = new Foo(); foreach($Foo as $key => &$value) { if ($key == 'foo') { echo 'we are hitting here' , PHP_EOL; $value = 'in the loop'; } } foreach($Foo as $key => $value) { echo $key, ':', $value, PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 126) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
Branch analysis from position: 13
filename:       /in/Nkq4E
function name:  (null)
number of ops:  24
compiled vars:  !0 = $Foo, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'foo'
   19     1        NEW                                              $3      'Foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   21     4      > FE_RESET_RW                                      $6      !0, ->13
          5    > > FE_FETCH_RW                                      ~7      $6, !1, ->13
          6    >   ASSIGN                                                   !2, ~7
   22     7        IS_EQUAL                                                 !2, 'foo'
          8      > JMPZ                                                     ~9, ->12
   23     9    >   ECHO                                                     'we+are+hitting+here'
         10        ECHO                                                     '%0A'
   24    11        ASSIGN                                                   !1, 'in+the+loop'
   21    12    > > JMP                                                      ->5
         13    >   FE_FREE                                                  $6
   29    14      > FE_RESET_R                                       $11     !0, ->22
         15    > > FE_FETCH_R                                       ~12     $11, !1, ->22
         16    >   ASSIGN                                                   !2, ~12
   30    17        ECHO                                                     !2
         18        ECHO                                                     '%3A'
         19        ECHO                                                     !1
         20        ECHO                                                     '%0A'
   29    21      > JMP                                                      ->15
         22    >   FE_FREE                                                  $11
   31    23      > RETURN                                                   1

Class Foo:
Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Nkq4E
function name:  getIterator
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $0      'ArrayIterator'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $1      'data'
          3        SEND_FUNC_ARG                                            $1
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $0
   14     6*     > RETURN                                                   null

End of function getiterator

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.13 ms | 1399 KiB | 13 Q