3v4l.org

run code in 500+ PHP versions simultaneously
<?php set_error_handler('error_handler'); // 無名関数によるコールバックは PHP5.3 から有効です function error_handler($errno, $errstr, $errfile, $errline) { // エラーの種別を定数から文字列化するための対応をまとめた連想配列 $errMap = array(// match式は PHP8 から、[]による配列宣言構文は PHP5.4 から有効です E_ERROR => 'ERROR', E_WARNING => 'WARNING', E_NOTICE => 'NOTICE', E_CORE_ERROR => 'CORE_ERROR', E_CORE_WARNING => 'CORE_WARNING', E_COMPILE_ERROR => 'COMPILE_ERROR', E_COMPILE_WARNING => 'COMPILE_WARNING', E_USER_ERROR => 'USER_ERROR', E_USER_WARNING => 'USER_WARNING', E_USER_NOTICE => 'USER_NOTICE', E_STRICT => 'STRICT', // E_RECOVERABLE_ERROR => 'RECOVERABLE_ERROR', // PHP5.2 から有効な定数です // E_DEPRECATED => 'DEPRECATED', // PHP5.3 から有効な定数です // E_USER_DEPRECATED => 'USER_DEPRECATED', // PHP5.3 から有効な定数です E_ALL => 'ALL', ); // 上記のエラー種別配列からエラーの種別を文字列化 // null 合体演算子は PHP7.0 から有効です $errLevel = isset($errMap[$errno]) ? $errMap[$errno] : 'UNKNOWN No.'.$errno; // エラーの内容を元に例外を投げます if (version_compare(PHP_VERSION, '5.1.0') >= 0) { // @see https://www.php.net/manual/ja/class.errorexception.php PHP: ErrorException - Manual // @see https://qiita.com/mpyw/items/c69da9589e72ceac470c お前は PHP 7 における Fatal Error / Catchable Fatal Error / Error / ErrorException / Exception の違いを言えるか? // PHP のエラーを例外に変換する時のための組み込み例外クラスのインスタンスを投げる throw new ErrorException("{$errLevel}: {$errstr} {$errfile} {$errline}", 0, $errno, $errfile, $errline); } elseif (version_compare(PHP_VERSION, '5.0.0') >= 0) { // PHP5.1 より前は ErrorException クラスが存在しないので代わりに Exception クラスを使う throw new Exception("{$errLevel}: {$errstr} {$errfile} {$errline}", 0, $errno, $errfile, $errline); } } // 例 echo $a; /* Fatal error: Uncaught ErrorException: WARNING: Undefined variable $a /in/ZBILA 32 in /in/ZBILA:32 Stack trace: #0 /in/ZBILA(32): error_handler(2, 'Undefined varia...', '/in/ZBILA', 32) #1 {main} thrown in /in/ZBILA on line 32 */
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tGHtO
function name:  (null)
number of ops:  5
compiled vars:  !0 = $a
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                                   'set_error_handler'
          1        SEND_VAL                                                     'error_handler'
          2        DO_ICALL                                                     
   41     3        ECHO                                                         !0
   48     4      > RETURN                                                       1

Function error_handler:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 48
Branch analysis from position: 32
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 69
Branch analysis from position: 54
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 48
Branch analysis from position: 32
Branch analysis from position: 48
filename:       /in/tGHtO
function name:  error_handler
number of ops:  70
compiled vars:  !0 = $errno, !1 = $errstr, !2 = $errfile, !3 = $errline, !4 = $errMap, !5 = $errLevel
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
          3        RECV                                                 !3      
    7     4        INIT_ARRAY                                           ~6      'ERROR', 1
    8     5        ADD_ARRAY_ELEMENT                                    ~6      'WARNING', 2
    9     6        ADD_ARRAY_ELEMENT                                    ~6      'NOTICE', 8
   10     7        ADD_ARRAY_ELEMENT                                    ~6      'CORE_ERROR', 16
   11     8        ADD_ARRAY_ELEMENT                                    ~6      'CORE_WARNING', 32
   12     9        ADD_ARRAY_ELEMENT                                    ~6      'COMPILE_ERROR', 64
   13    10        ADD_ARRAY_ELEMENT                                    ~6      'COMPILE_WARNING', 128
   14    11        ADD_ARRAY_ELEMENT                                    ~6      'USER_ERROR', 256
   15    12        ADD_ARRAY_ELEMENT                                    ~6      'USER_WARNING', 512
   16    13        ADD_ARRAY_ELEMENT                                    ~6      'USER_NOTICE', 1024
   17    14        FETCH_CONSTANT                                       ~7      'E_STRICT'
         15        ADD_ARRAY_ELEMENT                                    ~6      'STRICT', ~7
   21    16        ADD_ARRAY_ELEMENT                                    ~6      'ALL', 30719
    6    17        ASSIGN                                                       !4, ~6
   25    18        ISSET_ISEMPTY_DIM_OBJ                             0          !4, !0
         19      > JMPZ                                                         ~9, ->23
         20    >   FETCH_DIM_R                                          ~10     !4, !0
         21        QM_ASSIGN                                            ~11     ~10
         22      > JMP                                                          ->25
         23    >   CONCAT                                               ~12     'UNKNOWN+No.', !0
         24        QM_ASSIGN                                            ~11     ~12
         25    >   ASSIGN                                                       !5, ~11
   28    26        INIT_FCALL                                                   'version_compare'
         27        SEND_VAL                                                     '8.5.0'
         28        SEND_VAL                                                     '5.1.0'
         29        DO_ICALL                                             $14     
         30        IS_SMALLER_OR_EQUAL                                          0, $14
         31      > JMPZ                                                         ~15, ->48
   32    32    >   NEW                                                  $16     'ErrorException'
         33        ROPE_INIT                                         7  ~18     !5
         34        ROPE_ADD                                          1  ~18     ~18, '%3A+'
         35        ROPE_ADD                                          2  ~18     ~18, !1
         36        ROPE_ADD                                          3  ~18     ~18, '+'
         37        ROPE_ADD                                          4  ~18     ~18, !2
         38        ROPE_ADD                                          5  ~18     ~18, '+'
         39        ROPE_END                                          6  ~17     ~18, !3
         40        SEND_VAL_EX                                                  ~17
         41        SEND_VAL_EX                                                  0
         42        SEND_VAR_EX                                                  !0
         43        SEND_VAR_EX                                                  !2
         44        SEND_VAR_EX                                                  !3
         45        DO_FCALL                                          0          
         46      > THROW                                             0          $16
   28    47*       JMP                                                          ->69
   33    48    >   INIT_FCALL                                                   'version_compare'
         49        SEND_VAL                                                     '8.5.0'
         50        SEND_VAL                                                     '5.0.0'
         51        DO_ICALL                                             $23     
         52        IS_SMALLER_OR_EQUAL                                          0, $23
         53      > JMPZ                                                         ~24, ->69
   35    54    >   NEW                                                  $25     'Exception'
         55        ROPE_INIT                                         7  ~27     !5
         56        ROPE_ADD                                          1  ~27     ~27, '%3A+'
         57        ROPE_ADD                                          2  ~27     ~27, !1
         58        ROPE_ADD                                          3  ~27     ~27, '+'
         59        ROPE_ADD                                          4  ~27     ~27, !2
         60        ROPE_ADD                                          5  ~27     ~27, '+'
         61        ROPE_END                                          6  ~26     ~27, !3
         62        SEND_VAL_EX                                                  ~26
         63        SEND_VAL_EX                                                  0
         64        SEND_VAR_EX                                                  !0
         65        SEND_VAR_EX                                                  !2
         66        SEND_VAR_EX                                                  !3
         67        DO_FCALL                                          0          
         68      > THROW                                             0          $25
   37    69    > > RETURN                                                       null

End of function error_handler

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
219.4 ms | 3448 KiB | 15 Q