3v4l.org

run code in 300+ PHP versions simultaneously
<?php gc_collect_cycles(); class myclass { public function __construct () { echo("constructor\n"); } public function __destruct () { echo("destructor\n"); } } $t = new temp(); $t->dupa = 'ddd'; $t->test = new myclass(); $temp = array( 0 => $t ); echo("------------1-----------\n"); foreach ($temp as $key => $ttt) { //unset($temp[$key]['test']); // $temp[$key]->test = null; // $temp[$key] = null; unset($temp[$key]->test, $temp[$key], $temp); } echo("------------2-----------\n"); echo("------------3-----------\n"); // gc_collect_cycles(); // foreach (range(1, 100000) as $a) // { // echo PHP_EOL.$a.PHP_EOL; // } class temp { public $dupa; public $test; public function __destruct () { echo PHP_EOL.'TEMP D.'.PHP_EOL; unset($this->test); } }
Finding entry points
Branch analysis from position: 0
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
filename:       /in/5gptk
function name:  (null)
number of ops:  26
compiled vars:  !0 = $t, !1 = $temp, !2 = $ttt, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'gc_collect_cycles'
          1        DO_ICALL                                                 
   18     2        NEW                                              $5      'temp'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $5
   19     5        ASSIGN_OBJ                                               !0, 'dupa'
          6        OP_DATA                                                  'ddd'
   20     7        NEW                                              $10     'myclass'
          8        DO_FCALL                                      0          
          9        ASSIGN_OBJ                                               !0, 'test'
         10        OP_DATA                                                  $10
   22    11        INIT_ARRAY                                       ~12     !0, 0
   21    12        ASSIGN                                                   !1, ~12
   25    13        ECHO                                                     '------------1-----------%0A'
   26    14      > FE_RESET_R                                       $14     !1, ->22
         15    > > FE_FETCH_R                                       ~15     $14, !2, ->22
         16    >   ASSIGN                                                   !3, ~15
   31    17        FETCH_DIM_UNSET                                  $17     !1, !3
         18        UNSET_OBJ                                                $17, 'test'
         19        UNSET_DIM                                                !1, !3
         20        UNSET_CV                                                 !1
   26    21      > JMP                                                      ->15
         22    >   FE_FREE                                                  $14
   33    23        ECHO                                                     '------------2-----------%0A'
   34    24        ECHO                                                     '------------3-----------%0A'
   50    25      > RETURN                                                   1

Class myclass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5gptk
function name:  __construct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ECHO                                                     'constructor%0A'
   10     1      > RETURN                                                   null

End of function __construct

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5gptk
function name:  __destruct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ECHO                                                     'destructor%0A'
   15     1      > RETURN                                                   null

End of function __destruct

End of class myclass.

Class temp:
Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5gptk
function name:  __destruct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   ECHO                                                     '%0ATEMP+D.%0A'
   48     1        UNSET_OBJ                                                'test'
   49     2      > RETURN                                                   null

End of function __destruct

End of class temp.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.7 ms | 1400 KiB | 15 Q