3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NewException extends Exception { //$message is now not optional, just for the extension. public function __construct($message, $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); } } /** * TestException * Tests and throws Exceptions. */ class TestException { const NONE = 0; const NORMAL = 1; const CUSTOM = 2; public function __construct($type) { switch ($type) { case 1: throw new Exception('Normal Exception'); break; case 2: throw new NewException('Custom Exception'); break; default: return 0; //No exception is thrown. } } } try { $t = new TestException(TestException::CUSTOM); } catch (Exception $e) { print_r($e); //Exception Caught } ?>
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 = 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 = 62) Position 1 = -2
filename:       /in/7MB1t
function name:  (null)
number of ops:  10
compiled vars:  !0 = $t, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   NEW                                              $2      'TestException'
          1        SEND_VAL_EX                                              2
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
          4      > JMP                                                      ->9
   35     5  E > > CATCH                                       last         'Exception'
   36     6    >   INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   39     9    > > RETURN                                                   1

Class NewException:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7MB1t
function name:  __construct
number of ops:  9
compiled vars:  !0 = $message, !1 = $code, !2 = $previous
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
          2        RECV_INIT                                        !2      null
    6     3        INIT_STATIC_METHOD_CALL                                  
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0          
    7     8      > RETURN                                                   null

End of function __construct

End of class NewException.

Class TestException:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/7MB1t
function name:  __construct
number of ops:  18
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        IS_EQUAL                                                 !0, 1
          2      > JMPNZ                                                    ~1, ->6
   23     3    >   IS_EQUAL                                                 !0, 2
          4      > JMPNZ                                                    ~1, ->11
          5    > > JMP                                                      ->16
   21     6    >   NEW                                              $2      'Exception'
          7        SEND_VAL_EX                                              'Normal+Exception'
          8        DO_FCALL                                      0          
          9      > THROW                                         0          $2
   22    10*       JMP                                                      ->17
   24    11    >   NEW                                              $4      'NewException'
         12        SEND_VAL_EX                                              'Custom+Exception'
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $4
   25    15*       JMP                                                      ->17
   27    16    > > RETURN                                                   0
   29    17*     > RETURN                                                   null

End of function __construct

End of class TestException.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.74 ms | 1400 KiB | 15 Q