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 $q) { if ($q->getBar()) { unset($q); } } 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 = 17
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 16
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 30
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 30
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 29
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 17
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/fepWj
function name:  (null)
number of ops:  35
compiled vars:  !0 = $quux, !1 = $i, !2 = $q, !3 = $qwax
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                                              $7      'Foo'
          4        DO_FCALL                                      0          
          5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  $7
   17     7        PRE_INC                                                  !1
          8    >   IS_SMALLER                                               !1, 10
          9      > JMPNZ                                                    ~10, ->3
   21    10    > > FE_RESET_R                                       $11     !0, ->17
         11    > > FE_FETCH_R                                               $11, !2, ->17
   22    12    >   INIT_METHOD_CALL                                         !2, 'getBar'
         13        DO_FCALL                                      0  $12     
         14      > JMPZ                                                     $12, ->16
   23    15    >   UNSET_CV                                                 !2
   21    16    > > JMP                                                      ->11
         17    >   FE_FREE                                                  $11
   27    18        INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                                 
   29    21        ASSIGN                                                   !3, <array>
   31    22      > FE_RESET_R                                       $15     !0, ->30
         23    > > FE_FETCH_R                                               $15, !2, ->30
   32    24    >   INIT_METHOD_CALL                                         !2, 'getBar'
         25        DO_FCALL                                      0  $16     
         26      > JMPZ                                                     $16, ->29
   33    27    >   ASSIGN_DIM                                               !3
         28        OP_DATA                                                  !2
   31    29    > > JMP                                                      ->23
         30    >   FE_FREE                                                  $15
   37    31        INIT_FCALL                                               'print_r'
         32        SEND_VAR                                                 !3
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fepWj
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/fepWj
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:
152.66 ms | 1400 KiB | 17 Q