3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $id; function __construct($id=NULL) { $this->id = $id; print "construct\n"; } function __destruct() { if ($this->id === NULL) throw new Exception("destruct failed\n"); print "destruct\n"; } } try { $foo = new Foo(); unset($foo); } catch (Exception $e) { print $e->getMessage(); } print "done once\n\n"; try { $foo = new Foo("foo"); unset($foo); } catch (Exception $e) { print $e->getMessage(); } print "done twice";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 5
Branch analysis from position: 5
2 jumps found. (Code = 107) Position 1 = 6, Position 2 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Found catch point at position: 16
Branch analysis from position: 16
2 jumps found. (Code = 107) Position 1 = 17, Position 2 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5Kq9c
function name:  (null)
number of ops:  22
compiled vars:  !0 = $foo, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   18     3        UNSET_CV                                                 !0
          4      > JMP                                                      ->9
   19     5  E > > CATCH                                       last         'Exception'
   20     6    >   INIT_METHOD_CALL                                         !1, 'getMessage'
          7        DO_FCALL                                      0  $5      
          8        ECHO                                                     $5
   22     9    >   ECHO                                                     'done+once%0A%0A'
   24    10        NEW                                              $6      'Foo'
         11        SEND_VAL_EX                                              'foo'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !0, $6
   25    14        UNSET_CV                                                 !0
         15      > JMP                                                      ->20
   26    16  E > > CATCH                                       last         'Exception'
   27    17    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         18        DO_FCALL                                      0  $9      
         19        ECHO                                                     $9
   29    20    >   ECHO                                                     'done+twice'
         21      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5Kq9c
function name:  __construct
number of ops:  5
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV_INIT                                        !0      null
    6     1        ASSIGN_OBJ                                               'id'
          2        OP_DATA                                                  !0
    7     3        ECHO                                                     'construct%0A'
    8     4      > RETURN                                                   null

End of function __construct

Function __destruct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5Kq9c
function name:  __destruct
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FETCH_OBJ_R                                      ~0      'id'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
   11     3    >   NEW                                              $2      'Exception'
          4        SEND_VAL_EX                                              'destruct+failed%0A'
          5        DO_FCALL                                      0          
          6      > THROW                                         0          $2
   12     7    >   ECHO                                                     'destruct%0A'
   13     8      > RETURN                                                   null

End of function __destruct

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.59 ms | 1399 KiB | 13 Q