3v4l.org

run code in 300+ PHP versions simultaneously
<?php // 为避免污染全局命名空间,已对所有标识符加 `e` 前缀 /** * 运行模式 * * debug 调试模式, 会开启详细的日志记录和错误提示 * * default 默认模式, 会输出错误提示 * * production 生产模式, 不会执行任何额外操作, 最高效地执行代码 */ const eDebug = 2; const eDefault = 1; const eProduction = 0; const eRunMode = eDefault; // 默认关掉所有错误提示 error_reporting(0); // 如果是默认模式,打开致命错误和解析错误的报告 if(eRunMode >= eDefault) error_reporting(E_ERROR | E_PARSE); // 如果是调试模式,打开全部错误提示,并启用修改建议提示 if(eRunMode >= eDebug) error_reporting(E_ALL | E_STRICT); class ePHPException extends Exception { protected $severity; protected $varList; public function __construct($message = "", $code = 0, $severity = 1, $filename = __FILE__, $lineno = __LINE__, Exception $previous = null, $varList = []) { $this->severity = $severity; $this->file = $filename; $this->line = $lineno; $this->varList = $varList; // 调用父类的构造函数 parent::__construct($message, $code, $previous); } public function getSeverity() { return $this->severity; } public function getVarList() { return $this->varList; } } set_error_handler(function($no, $str, $file, $line, $varList) { throw new ePHPException($str, 0, $no, $file, $line, null, $varList); }); register_shutdown_function(function() { $error = error_get_last(); if($error['type'] === E_ERROR) throw new ePHPException($error['message'], 0, $error['type'], $error['file'], $error['line']); }); if(eRunMode <= eProduction) { set_exception_handler(function(Exception $exception) { header("Content-Type: text/plant; charset=UTF-8"); die(header("HTTP/1.1 500 Internal Server Error")); }); } else { set_exception_handler(function(Exception $exception) { // 暂时我们只打算以纯文本的形式展示信息 header("Content-Type: text/plant; charset=UTF-8"); // 整体模版 $msg = "Exception `%s`: %s\nStack trace:\n%s\n thrown in %s on line %s"; // 栈的每一行的模版 $traceline = "#%s %s (%s): %s(%s)"; // 从异常对象获取运行栈 $trace = $exception->getTrace(); // 只有在调试模式才会显示参数的值,其他模式下只显示参数类型 if(eRunMode < eDebug) foreach ($trace as $key => $stackPoint) $trace[$key]['args'] = array_map('gettype', $trace[$key]['args']); $result = []; // 对运行栈的每一项应用模版 foreach ($trace as $key => $stackPoint) $result[] = sprintf( $traceline, $key, $stackPoint['file'], $stackPoint['line'], $stackPoint['function'], implode(', ', $stackPoint['args']) ); $result[] = '#' . ++$key . ' {main}'; // 应用整体模版 $msg = sprintf( $msg, get_class($exception), $exception->getMessage(), implode("\n", $result), $exception->getFile(), $exception->getLine() ); // 打印运行栈等信息 print $msg; // 如果当前是调试模式,且异常对象是我们构造的 ePHPException 类型,打印符号表 if(eRunMode >= eDebug && $exception instanceof ePHPException) print_r($exception->getVarList()); }); } array_keys1();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 38
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 14
filename:       /in/fBaqK
function name:  (null)
number of ops:  45
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   DECLARE_CONST                                            'eDebug', 2
   13     1        DECLARE_CONST                                            'eDefault', 1
   14     2        DECLARE_CONST                                            'eProduction', 0
   16     3        DECLARE_CONST                                            'eRunMode', <const ast>
   19     4        INIT_FCALL                                               'error_reporting'
          5        SEND_VAL                                                 0
          6        DO_ICALL                                                 
   21     7        FETCH_CONSTANT                                   ~1      'eRunMode'
          8        FETCH_CONSTANT                                   ~2      'eDefault'
          9        IS_SMALLER_OR_EQUAL                                      ~2, ~1
         10      > JMPZ                                                     ~3, ->14
   22    11    >   INIT_FCALL                                               'error_reporting'
         12        SEND_VAL                                                 5
         13        DO_ICALL                                                 
   24    14    >   FETCH_CONSTANT                                   ~5      'eRunMode'
         15        FETCH_CONSTANT                                   ~6      'eDebug'
         16        IS_SMALLER_OR_EQUAL                                      ~6, ~5
         17      > JMPZ                                                     ~7, ->21
   25    18    >   INIT_FCALL                                               'error_reporting'
         19        SEND_VAL                                                 32767
         20        DO_ICALL                                                 
   54    21    >   INIT_FCALL                                               'set_error_handler'
         22        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfBaqK%3A54%240'
   57    23        SEND_VAL                                                 ~9
         24        DO_ICALL                                                 
   59    25        INIT_FCALL                                               'register_shutdown_function'
         26        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfBaqK%3A59%241'
   63    27        SEND_VAL                                                 ~11
         28        DO_ICALL                                                 
   65    29        FETCH_CONSTANT                                   ~13     'eRunMode'
         30        FETCH_CONSTANT                                   ~14     'eProduction'
         31        IS_SMALLER_OR_EQUAL                                      ~13, ~14
         32      > JMPZ                                                     ~15, ->38
   67    33    >   INIT_FCALL                                               'set_exception_handler'
         34        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfBaqK%3A67%242'
   71    35        SEND_VAL                                                 ~16
         36        DO_ICALL                                                 
         37      > JMP                                                      ->42
   75    38    >   INIT_FCALL                                               'set_exception_handler'
         39        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfBaqK%3A75%243'
  123    40        SEND_VAL                                                 ~18
         41        DO_ICALL                                                 
  128    42    >   INIT_FCALL_BY_NAME                                       'array_keys1'
         43        DO_FCALL                                      0          
         44      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FfBaqK%3A54%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/fBaqK
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $no, !1 = $str, !2 = $file, !3 = $line, !4 = $varList
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
   56     5        NEW                                              $5      'ePHPException'
          6        SEND_VAR_EX                                              !1
          7        SEND_VAL_EX                                              0
          8        SEND_VAR_EX                                              !0
          9        SEND_VAR_EX                                              !2
         10        SEND_VAR_EX                                              !3
         11        SEND_VAL_EX                                              null
         12        SEND_VAR_EX                                              !4
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $5
   57    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FfBaqK%3A54%240

Function %00%7Bclosure%7D%2Fin%2FfBaqK%3A59%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 22
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fBaqK
function name:  {closure}
number of ops:  23
compiled vars:  !0 = $error
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   INIT_FCALL                                               'error_get_last'
          1        DO_ICALL                                         $1      
          2        ASSIGN                                                   !0, $1
   61     3        FETCH_DIM_R                                      ~3      !0, 'type'
          4        IS_IDENTICAL                                             ~3, 1
          5      > JMPZ                                                     ~4, ->22
   62     6    >   NEW                                              $5      'ePHPException'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_DIM_FUNC_ARG                               $6      !0, 'message'
          9        SEND_FUNC_ARG                                            $6
         10        SEND_VAL_EX                                              0
         11        CHECK_FUNC_ARG                                           
         12        FETCH_DIM_FUNC_ARG                               $7      !0, 'type'
         13        SEND_FUNC_ARG                                            $7
         14        CHECK_FUNC_ARG                                           
         15        FETCH_DIM_FUNC_ARG                               $8      !0, 'file'
         16        SEND_FUNC_ARG                                            $8
         17        CHECK_FUNC_ARG                                           
         18        FETCH_DIM_FUNC_ARG                               $9      !0, 'line'
         19        SEND_FUNC_ARG                                            $9
         20        DO_FCALL                                      0          
         21      > THROW                                         0          $5
   63    22    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FfBaqK%3A59%241

Function %00%7Bclosure%7D%2Fin%2FfBaqK%3A67%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/fBaqK
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $exception
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   RECV                                             !0      
   68     1        INIT_FCALL                                               'header'
          2        SEND_VAL                                                 'Content-Type%3A+text%2Fplant%3B+charset%3DUTF-8'
          3        DO_ICALL                                                 
   70     4        INIT_FCALL                                               'header'
          5        SEND_VAL                                                 'HTTP%2F1.1+500+Internal+Server+Error'
          6        DO_ICALL                                         $2      
          7      > EXIT                                                     $2
   71     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FfBaqK%3A67%242

Function %00%7Bclosure%7D%2Fin%2FfBaqK%3A75%243:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 26
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 26
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 50
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 50
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 50
2 jumps found. (Code = 46) Position 1 = 81, Position 2 = 83
Branch analysis from position: 81
2 jumps found. (Code = 43) Position 1 = 84, Position 2 = 89
Branch analysis from position: 84
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 89
Branch analysis from position: 83
Branch analysis from position: 50
Branch analysis from position: 26
Branch analysis from position: 27
filename:       /in/fBaqK
function name:  {closure}
number of ops:  90
compiled vars:  !0 = $exception, !1 = $msg, !2 = $traceline, !3 = $trace, !4 = $stackPoint, !5 = $key, !6 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   75     0  E >   RECV                                             !0      
   77     1        INIT_FCALL                                               'header'
          2        SEND_VAL                                                 'Content-Type%3A+text%2Fplant%3B+charset%3DUTF-8'
          3        DO_ICALL                                                 
   80     4        ASSIGN                                                   !1, 'Exception+%60%25s%60%3A+%25s%0AStack+trace%3A%0A%25s%0A++thrown+in+%25s+on+line+%25s'
   82     5        ASSIGN                                                   !2, '%23%25s+%25s+%28%25s%29%3A+%25s%28%25s%29'
   85     6        INIT_METHOD_CALL                                         !0, 'getTrace'
          7        DO_FCALL                                      0  $10     
          8        ASSIGN                                                   !3, $10
   88     9        FETCH_CONSTANT                                   ~12     'eRunMode'
         10        FETCH_CONSTANT                                   ~13     'eDebug'
         11        IS_SMALLER                                               ~12, ~13
         12      > JMPZ                                                     ~14, ->27
   89    13    > > FE_RESET_R                                       $15     !3, ->26
         14    > > FE_FETCH_R                                       ~16     $15, !4, ->26
         15    >   ASSIGN                                                   !5, ~16
   90    16        INIT_FCALL                                               'array_map'
         17        SEND_VAL                                                 'gettype'
         18        FETCH_DIM_R                                      ~20     !3, !5
         19        FETCH_DIM_R                                      ~21     ~20, 'args'
         20        SEND_VAL                                                 ~21
         21        DO_ICALL                                         $22     
         22        FETCH_DIM_W                                      $18     !3, !5
         23        ASSIGN_DIM                                               $18, 'args'
         24        OP_DATA                                                  $22
   89    25      > JMP                                                      ->14
         26    >   FE_FREE                                                  $15
   92    27    >   ASSIGN                                                   !6, <array>
   95    28      > FE_RESET_R                                       $24     !3, ->50
         29    > > FE_FETCH_R                                       ~25     $24, !4, ->50
         30    >   ASSIGN                                                   !5, ~25
   96    31        INIT_FCALL                                               'sprintf'
   97    32        SEND_VAR                                                 !2
   98    33        SEND_VAR                                                 !5
   99    34        FETCH_DIM_R                                      ~28     !4, 'file'
         35        SEND_VAL                                                 ~28
  100    36        FETCH_DIM_R                                      ~29     !4, 'line'
         37        SEND_VAL                                                 ~29
  101    38        FETCH_DIM_R                                      ~30     !4, 'function'
         39        SEND_VAL                                                 ~30
  102    40        INIT_FCALL                                               'implode'
         41        SEND_VAL                                                 '%2C+'
         42        FETCH_DIM_R                                      ~31     !4, 'args'
         43        SEND_VAL                                                 ~31
         44        DO_ICALL                                         $32     
         45        SEND_VAR                                                 $32
         46        DO_ICALL                                         $33     
   96    47        ASSIGN_DIM                                               !6
  102    48        OP_DATA                                                  $33
   95    49      > JMP                                                      ->29
         50    >   FE_FREE                                                  $24
  105    51        PRE_INC                                          ~35     !5
         52        CONCAT                                           ~36     '%23', ~35
         53        CONCAT                                           ~37     ~36, '+%7Bmain%7D'
         54        ASSIGN_DIM                                               !6
         55        OP_DATA                                                  ~37
  108    56        INIT_FCALL                                               'sprintf'
  109    57        SEND_VAR                                                 !1
  110    58        GET_CLASS                                        ~38     !0
         59        SEND_VAL                                                 ~38
  111    60        INIT_METHOD_CALL                                         !0, 'getMessage'
         61        DO_FCALL                                      0  $39     
         62        SEND_VAR                                                 $39
  112    63        INIT_FCALL                                               'implode'
         64        SEND_VAL                                                 '%0A'
         65        SEND_VAR                                                 !6
         66        DO_ICALL                                         $40     
         67        SEND_VAR                                                 $40
  113    68        INIT_METHOD_CALL                                         !0, 'getFile'
         69        DO_FCALL                                      0  $41     
         70        SEND_VAR                                                 $41
  114    71        INIT_METHOD_CALL                                         !0, 'getLine'
         72        DO_FCALL                                      0  $42     
         73        SEND_VAR                                                 $42
         74        DO_ICALL                                         $43     
  108    75        ASSIGN                                                   !1, $43
  118    76        ECHO                                                     !1
  121    77        FETCH_CONSTANT                                   ~45     'eRunMode'
         78        FETCH_CONSTANT                                   ~46     'eDebug'
         79        IS_SMALLER_OR_EQUAL                              ~47     ~46, ~45
         80      > JMPZ_EX                                          ~47     ~47, ->83
         81    >   INSTANCEOF                                       ~48     !0, 'ePHPException'
         82        BOOL                                             ~47     ~48
         83    > > JMPZ                                                     ~47, ->89
  122    84    >   INIT_FCALL                                               'print_r'
         85        INIT_METHOD_CALL                                         !0, 'getVarList'
         86        DO_FCALL                                      0  $49     
         87        SEND_VAR                                                 $49
         88        DO_ICALL                                                 
  123    89    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FfBaqK%3A75%243

Class ePHPException:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fBaqK
function name:  __construct
number of ops:  21
compiled vars:  !0 = $message, !1 = $code, !2 = $severity, !3 = $filename, !4 = $lineno, !5 = $previous, !6 = $varList
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV_INIT                                        !0      ''
          1        RECV_INIT                                        !1      0
          2        RECV_INIT                                        !2      1
          3        RECV_INIT                                        !3      '%2Fin%2FfBaqK'
          4        RECV_INIT                                        !4      32
          5        RECV_INIT                                        !5      null
          6        RECV_INIT                                        !6      <array>
   34     7        ASSIGN_OBJ                                               'severity'
          8        OP_DATA                                                  !2
   35     9        ASSIGN_OBJ                                               'file'
         10        OP_DATA                                                  !3
   36    11        ASSIGN_OBJ                                               'line'
         12        OP_DATA                                                  !4
   37    13        ASSIGN_OBJ                                               'varList'
         14        OP_DATA                                                  !6
   40    15        INIT_STATIC_METHOD_CALL                                  
         16        SEND_VAR_EX                                              !0
         17        SEND_VAR_EX                                              !1
         18        SEND_VAR_EX                                              !5
         19        DO_FCALL                                      0          
   41    20      > RETURN                                                   null

End of function __construct

Function getseverity:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fBaqK
function name:  getSeverity
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   FETCH_OBJ_R                                      ~0      'severity'
          1      > RETURN                                                   ~0
   46     2*     > RETURN                                                   null

End of function getseverity

Function getvarlist:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fBaqK
function name:  getVarList
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   FETCH_OBJ_R                                      ~0      'varList'
          1      > RETURN                                                   ~0
   51     2*     > RETURN                                                   null

End of function getvarlist

End of class ePHPException.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.31 ms | 1408 KiB | 33 Q