3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $bar; public function __construct() { $this->bar = rand(0, 1); } public function getBar() { return $this->bar; } } $quux = array(); for ($i=0; $i<10; $i++){ $quux[] = new Foo(); } foreach ($quux as $k => $v) { if ($v->getBar()) { unset($quux[$k]); } } print_r($quux); $qwax = array(); foreach ($quux as $q) { if ($q->getBar()) { $qwax[] = $q; } } print_r($qwax);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 17
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 31
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 30
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 18
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
Branch analysis from position: 3
filename:       /in/I1NWa
function name:  (null)
number of ops:  36
compiled vars:  !0 = $quux, !1 = $i, !2 = $v, !3 = $k, !4 = $qwax, !5 = $q
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   17     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->8
   18     3    >   NEW                                              $9      'Foo'
          4        DO_FCALL                                      0          
          5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  $9
   17     7        PRE_INC                                                  !1
          8    >   IS_SMALLER                                               !1, 10
          9      > JMPNZ                                                    ~12, ->3
   21    10    > > FE_RESET_R                                       $13     !0, ->18
         11    > > FE_FETCH_R                                       ~14     $13, !2, ->18
         12    >   ASSIGN                                                   !3, ~14
   22    13        INIT_METHOD_CALL                                         !2, 'getBar'
         14        DO_FCALL                                      0  $16     
         15      > JMPZ                                                     $16, ->17
   23    16    >   UNSET_DIM                                                !0, !3
   21    17    > > JMP                                                      ->11
         18    >   FE_FREE                                                  $13
   27    19        INIT_FCALL                                               'print_r'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                                 
   29    22        ASSIGN                                                   !4, <array>
   31    23      > FE_RESET_R                                       $19     !0, ->31
         24    > > FE_FETCH_R                                               $19, !5, ->31
   32    25    >   INIT_METHOD_CALL                                         !5, 'getBar'
         26        DO_FCALL                                      0  $20     
         27      > JMPZ                                                     $20, ->30
   33    28    >   ASSIGN_DIM                                               !4
         29        OP_DATA                                                  !5
   31    30    > > JMP                                                      ->24
         31    >   FE_FREE                                                  $19
   37    32        INIT_FCALL                                               'print_r'
         33        SEND_VAR                                                 !4
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/I1NWa
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'rand'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 1
          3        DO_ICALL                                         $1      
          4        ASSIGN_OBJ                                               'bar'
          5        OP_DATA                                                  $1
    8     6      > RETURN                                                   null

End of function __construct

Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/I1NWa
function name:  getBar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1      > RETURN                                                   ~0
   12     2*     > RETURN                                                   null

End of function getbar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.08 ms | 1400 KiB | 17 Q