3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foobar { public $baz; function __destruct() { # Don't do either of these, if $baz also has a __destruct()! $this->baz = null; unset($this->baz); # Instead, don't clear it at all, or do this: $this->baz->__destruct(); } } # Some function that throws an exception function fail($foobar) { throw new Exception("Exception A!"); } $foobar = new Foobar(); $foobar->baz = new Foobar(); try { fail($foobar); // Send foobar to func that throws an Exception } catch( Exception $e ) { print $e->getMessage(); // Exception A will be caught and printed, as expected. } $foobar = null; // clearing foobar, and its property $baz try { print 'Exception B:';// this will be printed // output stops here. throw new Exception("Exception B!"); } catch( Exception $e ) { print $e->getMessage(); // doesn't happen } print 'End'; // this won't be printed ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
Found catch point at position: 11
Branch analysis from position: 11
2 jumps found. (Code = 107) Position 1 = 12, Position 2 = -2
Branch analysis from position: 12
1 jumps found. (Code = 108) Position 1 = -2
Found catch point at position: 22
Branch analysis from position: 22
2 jumps found. (Code = 107) Position 1 = 23, Position 2 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WpIMP
function name:  (null)
number of ops:  28
compiled vars:  !0 = $foobar, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $2      'Foobar'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   20     3        NEW                                              $6      'Foobar'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               !0, 'baz'
          6        OP_DATA                                                  $6
   23     7        INIT_FCALL                                               'fail'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0          
         10      > JMP                                                      ->15
   24    11  E > > CATCH                                       last         'Exception'
   25    12    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         13        DO_FCALL                                      0  $9      
         14        ECHO                                                     $9
   28    15    >   ASSIGN                                                   !0, null
   31    16        ECHO                                                     'Exception+B%3A'
   33    17        NEW                                              $11     'Exception'
         18        SEND_VAL_EX                                              'Exception+B%21'
         19        DO_FCALL                                      0          
         20      > THROW                                         0          $11
         21*       JMP                                                      ->26
   34    22  E > > CATCH                                       last         'Exception'
   35    23    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         24        DO_FCALL                                      0  $13     
         25        ECHO                                                     $13
   37    26        ECHO                                                     'End'
   38    27      > RETURN                                                   1

Function fail:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/WpIMP
function name:  fail
number of ops:  6
compiled vars:  !0 = $foobar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        NEW                                              $1      'Exception'
          2        SEND_VAL_EX                                              'Exception+A%21'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $1
   17     5*     > RETURN                                                   null

End of function fail

Class Foobar:
Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WpIMP
function name:  __destruct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN_OBJ                                               'baz'
          1        OP_DATA                                                  null
    7     2        UNSET_OBJ                                                'baz'
   10     3        FETCH_OBJ_R                                      ~1      'baz'
          4        INIT_METHOD_CALL                                         ~1, '__destruct'
          5        DO_FCALL                                      0          
   11     6      > RETURN                                                   null

End of function __destruct

End of class Foobar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.41 ms | 1403 KiB | 14 Q