3v4l.org

run code in 300+ 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 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 35
Branch analysis from position: 19
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 56
Branch analysis from position: 41
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 35
Branch analysis from position: 19
Branch analysis from position: 35
filename:       /in/tGHtO
function name:  error_handler
number of ops:  57
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      
    6     4        ASSIGN                                                   !4, <array>
   25     5        ISSET_ISEMPTY_DIM_OBJ                         0          !4, !0
          6      > JMPZ                                                     ~7, ->10
          7    >   FETCH_DIM_R                                      ~8      !4, !0
          8        QM_ASSIGN                                        ~9      ~8
          9      > JMP                                                      ->12
         10    >   CONCAT                                           ~10     'UNKNOWN+No.', !0
         11        QM_ASSIGN                                        ~9      ~10
         12    >   ASSIGN                                                   !5, ~9
   28    13        INIT_FCALL                                               'version_compare'
         14        SEND_VAL                                                 '8.3.0'
         15        SEND_VAL                                                 '5.1.0'
         16        DO_ICALL                                         $12     
         17        IS_SMALLER_OR_EQUAL                                      0, $12
         18      > JMPZ                                                     ~13, ->35
   32    19    >   NEW                                              $14     'ErrorException'
         20        ROPE_INIT                                     7  ~16     !5
         21        ROPE_ADD                                      1  ~16     ~16, '%3A+'
         22        ROPE_ADD                                      2  ~16     ~16, !1
         23        ROPE_ADD                                      3  ~16     ~16, '+'
         24        ROPE_ADD                                      4  ~16     ~16, !2
         25        ROPE_ADD                                      5  ~16     ~16, '+'
         26        ROPE_END                                      6  ~15     ~16, !3
         27        SEND_VAL_EX                                              ~15
         28        SEND_VAL_EX                                              0
         29        SEND_VAR_EX                                              !0
         30        SEND_VAR_EX                                              !2
         31        SEND_VAR_EX                                              !3
         32        DO_FCALL                                      0          
         33      > THROW                                         0          $14
   28    34*       JMP                                                      ->56
   33    35    >   INIT_FCALL                                               'version_compare'
         36        SEND_VAL                                                 '8.3.0'
         37        SEND_VAL                                                 '5.0.0'
         38        DO_ICALL                                         $21     
         39        IS_SMALLER_OR_EQUAL                                      0, $21
         40      > JMPZ                                                     ~22, ->56
   35    41    >   NEW                                              $23     'Exception'
         42        ROPE_INIT                                     7  ~25     !5
         43        ROPE_ADD                                      1  ~25     ~25, '%3A+'
         44        ROPE_ADD                                      2  ~25     ~25, !1
         45        ROPE_ADD                                      3  ~25     ~25, '+'
         46        ROPE_ADD                                      4  ~25     ~25, !2
         47        ROPE_ADD                                      5  ~25     ~25, '+'
         48        ROPE_END                                      6  ~24     ~25, !3
         49        SEND_VAL_EX                                              ~24
         50        SEND_VAL_EX                                              0
         51        SEND_VAR_EX                                              !0
         52        SEND_VAR_EX                                              !2
         53        SEND_VAR_EX                                              !3
         54        DO_FCALL                                      0          
         55      > THROW                                         0          $23
   37    56    > > RETURN                                                   null

End of function error_handler

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.19 ms | 1465 KiB | 15 Q