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"; } } print "<pre>"; 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 = 10
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 6
Branch analysis from position: 6
2 jumps found. (Code = 107) Position 1 = 7, Position 2 = -2
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Found catch point at position: 17
Branch analysis from position: 17
2 jumps found. (Code = 107) Position 1 = 18, Position 2 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/POBo9
function name:  (null)
number of ops:  23
compiled vars:  !0 = $foo, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ECHO                                                     '%3Cpre%3E'
   18     1        NEW                                              $2      'Foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   19     4        UNSET_CV                                                 !0
          5      > JMP                                                      ->10
   20     6  E > > CATCH                                       last         'Exception'
   21     7    >   INIT_METHOD_CALL                                         !1, 'getMessage'
          8        DO_FCALL                                      0  $5      
          9        ECHO                                                     $5
   23    10    >   ECHO                                                     'done+once%0A%0A'
   25    11        NEW                                              $6      'Foo'
         12        SEND_VAL_EX                                              'foo'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !0, $6
   26    15        UNSET_CV                                                 !0
         16      > JMP                                                      ->21
   27    17  E > > CATCH                                       last         'Exception'
   28    18    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         19        DO_FCALL                                      0  $9      
         20        ECHO                                                     $9
   30    21    >   ECHO                                                     'done+twice'
         22      > RETURN                                                   1

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