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; } public function nullify() { unset($this->bar); } } $quux = array(); for ($i=0; $i<10; $i++){ $quux[] = new Foo(); } foreach ($quux as $q) { if ($q->getBar()) { unset($q); } } echo '<pre>'; print_r($quux); echo '</pre>'; $qwax = array(); foreach ($quux as $q) { if ($q->getBar()) { $qwax[] = $q; } } echo '<pre>'; print_r($qwax); echo '</pre>';
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 = 25, Position 2 = 32
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 32
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 31
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
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/NBTdl
function name:  (null)
number of ops:  39
compiled vars:  !0 = $quux, !1 = $i, !2 = $q, !3 = $qwax
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, <array>
   21     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->8
   22     3    >   NEW                                              $7      'Foo'
          4        DO_FCALL                                      0          
          5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  $7
   21     7        PRE_INC                                                  !1
          8    >   IS_SMALLER                                               !1, 10
          9      > JMPNZ                                                    ~10, ->3
   25    10    > > FE_RESET_R                                       $11     !0, ->17
         11    > > FE_FETCH_R                                               $11, !2, ->17
   26    12    >   INIT_METHOD_CALL                                         !2, 'getBar'
         13        DO_FCALL                                      0  $12     
         14      > JMPZ                                                     $12, ->16
   27    15    >   UNSET_CV                                                 !2
   25    16    > > JMP                                                      ->11
         17    >   FE_FREE                                                  $11
   31    18        ECHO                                                     '%3Cpre%3E'
         19        INIT_FCALL                                               'print_r'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                                 
         22        ECHO                                                     '%3C%2Fpre%3E'
   33    23        ASSIGN                                                   !3, <array>
   35    24      > FE_RESET_R                                       $15     !0, ->32
         25    > > FE_FETCH_R                                               $15, !2, ->32
   36    26    >   INIT_METHOD_CALL                                         !2, 'getBar'
         27        DO_FCALL                                      0  $16     
         28      > JMPZ                                                     $16, ->31
   37    29    >   ASSIGN_DIM                                               !3
         30        OP_DATA                                                  !2
   35    31    > > JMP                                                      ->25
         32    >   FE_FREE                                                  $15
   41    33        ECHO                                                     '%3Cpre%3E'
         34        INIT_FCALL                                               'print_r'
         35        SEND_VAR                                                 !3
         36        DO_ICALL                                                 
         37        ECHO                                                     '%3C%2Fpre%3E'
         38      > RETURN                                                   1

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

Function nullify:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NBTdl
function name:  nullify
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   UNSET_OBJ                                                'bar'
   16     1      > RETURN                                                   null

End of function nullify

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.65 ms | 1392 KiB | 17 Q