3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('log_errors','off'); // log_errors_max_len = infinite length ini_set("log_errors_max_len",0); function long_exception_handler($exception) { // for compatibility, call __toString echo $exception->__toString(); } set_exception_handler('long_exception_handler'); /** * NewException * Extends the Exception class so that the $message parameter is now mendatory. * */ 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 = self::NONE) { 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 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
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/IgW01
function name:  (null)
number of ops:  21
compiled vars:  !0 = $t, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'ini_set'
          1        SEND_VAL                                                 'log_errors'
          2        SEND_VAL                                                 'off'
          3        DO_ICALL                                                 
    5     4        INIT_FCALL                                               'ini_set'
          5        SEND_VAL                                                 'log_errors_max_len'
          6        SEND_VAL                                                 0
          7        DO_ICALL                                                 
   13     8        INIT_FCALL                                               'set_exception_handler'
          9        SEND_VAL                                                 'long_exception_handler'
         10        DO_ICALL                                                 
   50    11        NEW                                              $5      'TestException'
         12        SEND_VAL_EX                                              2
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !0, $5
         15      > JMP                                                      ->20
   52    16  E > > CATCH                                       last         'Exception'
   53    17    >   INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                                 
   56    20    > > RETURN                                                   1

Function long_exception_handler:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IgW01
function name:  long_exception_handler
number of ops:  5
compiled vars:  !0 = $exception
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        INIT_METHOD_CALL                                         !0, '__toString'
          2        DO_FCALL                                      0  $1      
          3        ECHO                                                     $1
   12     4      > RETURN                                                   null

End of function long_exception_handler

Class NewException:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IgW01
function name:  __construct
number of ops:  9
compiled vars:  !0 = $message, !1 = $code, !2 = $previous
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
          2        RECV_INIT                                        !2      null
   23     3        INIT_STATIC_METHOD_CALL                                  
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0          
   24     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/IgW01
function name:  __construct
number of ops:  18
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV_INIT                                        !0      <const ast>
   37     1        IS_EQUAL                                                 !0, 1
          2      > JMPNZ                                                    ~1, ->6
   40     3    >   IS_EQUAL                                                 !0, 2
          4      > JMPNZ                                                    ~1, ->11
          5    > > JMP                                                      ->16
   38     6    >   NEW                                              $2      'Exception'
          7        SEND_VAL_EX                                              'Normal+Exception'
          8        DO_FCALL                                      0          
          9      > THROW                                         0          $2
   39    10*       JMP                                                      ->17
   41    11    >   NEW                                              $4      'NewException'
         12        SEND_VAL_EX                                              'Custom+Exception'
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $4
   42    15*       JMP                                                      ->17
   44    16    > > RETURN                                                   0
   46    17*     > RETURN                                                   null

End of function __construct

End of class TestException.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.48 ms | 1400 KiB | 19 Q