3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ErrorLog { /*static*/ var $errorArr = array(); /*public static*/ function throwError ($err, $level = E_USER_WARNING, $suppress = false, $shiftBack = 1) { // Shiftback means: look back into the backtrace calls, shifting that amount of calls, and then report the error. // There is no checking whether this many levels actually exist in the call stack, make sure yourself // Error log doesn't show newlines. str_replace( array( "\n" ), array( " " ), $err ); $trace = ErrorLog::getBacktrace(); $info = ""; if (!empty($trace)) { while ($shiftBack > 0) { array_shift($trace); --$shiftBack; } // Error file/line information: $info .= "in " . $trace[0]["file"] . ":" . $trace[0]["line"] . "."; // Caller information: if (count($trace) > 1) { array_shift($trace); $caller = $trace[0]; $info .= " Thrown by "; if (isset($caller["function"])) { if (isset($caller["class"])) { $info .= $caller["class"] . "::"; } $info .= $caller["function"] . "() "; } else { $info .= "global scope "; } $info .= "which was called in " . $caller["file"] . ":" . $caller["line"] . "."; } } $queryStr = $_SERVER["QUERY_STRING"]; $info .= " (Called URL: " . $_SERVER["HOST_NAME"] . $_SERVER["PHP_SELF"] . (!empty($queryStr) ? ("?" . $queryStr) : "") . ")"; $out = "\"" . $err . "\" " . $info; ErrorLog::$errorArr[] = $err; if (!$suppress) { trigger_error($out, $level); } } /*public static*/ function throwDeprecated ($suppress = false) { // Call this method from INSIDE a deprecated function, ErrorLog::throwError("Deprecated!", E_USER_NOTICE, $suppress, 2); } /*public static*/ function hasErrors () { return (!empty(ErrorLog::$errorArr)); } /*private static*/ function getBacktrace () { if (version_compare(PHP_VERSION, "5.2.5", "<")) { return debug_backtrace(); } else { return debug_backtrace(false); // A bit more efficient } } } function a () { ErrorLog::throwDeprecated(); } a();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mVhXG
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   97     0  E >   INIT_FCALL                                               'a'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   1

Function a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mVhXG
function name:  a
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   94     0  E >   INIT_STATIC_METHOD_CALL                                  'ErrorLog', 'throwDeprecated'
          1        DO_FCALL                                      0          
   95     2      > RETURN                                                   null

End of function a

Class ErrorLog:
Function throwerror:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 60
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 17
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 60
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 52
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 48
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 75
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 76
Branch analysis from position: 76
2 jumps found. (Code = 43) Position 1 = 88, Position 2 = 92
Branch analysis from position: 88
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 92
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 88, Position 2 = 92
Branch analysis from position: 88
Branch analysis from position: 92
Branch analysis from position: 48
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 75
Branch analysis from position: 72
Branch analysis from position: 75
Branch analysis from position: 60
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 17
Branch analysis from position: 23
Branch analysis from position: 17
Branch analysis from position: 60
filename:       /in/mVhXG
function name:  throwError
number of ops:  93
compiled vars:  !0 = $err, !1 = $level, !2 = $suppress, !3 = $shiftBack, !4 = $trace, !5 = $info, !6 = $caller, !7 = $queryStr, !8 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <const ast>
          2        RECV_INIT                                        !2      <false>
          3        RECV_INIT                                        !3      1
   15     4        INIT_FCALL                                               'str_replace'
   17     5        SEND_VAL                                                 <array>
   20     6        SEND_VAL                                                 <array>
   22     7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
   25     9        INIT_STATIC_METHOD_CALL                                  'ErrorLog', 'getBacktrace'
         10        DO_FCALL                                      0  $10     
         11        ASSIGN                                                   !4, $10
   27    12        ASSIGN                                                   !5, ''
   29    13        ISSET_ISEMPTY_CV                                 ~13     !4
         14        BOOL_NOT                                         ~14     ~13
         15      > JMPZ                                                     ~14, ->60
   30    16    > > JMP                                                      ->21
   31    17    >   INIT_FCALL                                               'array_shift'
         18        SEND_REF                                                 !4
         19        DO_ICALL                                                 
   32    20        PRE_DEC                                                  !3
   30    21    >   IS_SMALLER                                               0, !3
         22      > JMPNZ                                                    ~17, ->17
   36    23    >   FETCH_DIM_R                                      ~18     !4, 0
         24        FETCH_DIM_R                                      ~19     ~18, 'file'
         25        CONCAT                                           ~20     'in+', ~19
         26        CONCAT                                           ~21     ~20, '%3A'
         27        FETCH_DIM_R                                      ~22     !4, 0
         28        FETCH_DIM_R                                      ~23     ~22, 'line'
         29        CONCAT                                           ~24     ~21, ~23
         30        CONCAT                                           ~25     ~24, '.'
         31        ASSIGN_OP                                     8          !5, ~25
   39    32        COUNT                                            ~27     !4
         33        IS_SMALLER                                               1, ~27
         34      > JMPZ                                                     ~28, ->60
   40    35    >   INIT_FCALL                                               'array_shift'
         36        SEND_REF                                                 !4
         37        DO_ICALL                                                 
   41    38        FETCH_DIM_R                                      ~30     !4, 0
         39        ASSIGN                                                   !6, ~30
   43    40        ASSIGN_OP                                     8          !5, '+Thrown+by+'
   44    41        ISSET_ISEMPTY_DIM_OBJ                         0          !6, 'function'
         42      > JMPZ                                                     ~33, ->52
   45    43    >   ISSET_ISEMPTY_DIM_OBJ                         0          !6, 'class'
         44      > JMPZ                                                     ~34, ->48
   46    45    >   FETCH_DIM_R                                      ~35     !6, 'class'
         46        CONCAT                                           ~36     ~35, '%3A%3A'
         47        ASSIGN_OP                                     8          !5, ~36
   48    48    >   FETCH_DIM_R                                      ~38     !6, 'function'
         49        CONCAT                                           ~39     ~38, '%28%29+'
         50        ASSIGN_OP                                     8          !5, ~39
         51      > JMP                                                      ->53
   50    52    >   ASSIGN_OP                                     8          !5, 'global+scope+'
   52    53    >   FETCH_DIM_R                                      ~42     !6, 'file'
         54        CONCAT                                           ~43     'which+was+called+in+', ~42
         55        CONCAT                                           ~44     ~43, '%3A'
         56        FETCH_DIM_R                                      ~45     !6, 'line'
         57        CONCAT                                           ~46     ~44, ~45
         58        CONCAT                                           ~47     ~46, '.'
         59        ASSIGN_OP                                     8          !5, ~47
   56    60    >   FETCH_R                      global              ~49     '_SERVER'
         61        FETCH_DIM_R                                      ~50     ~49, 'QUERY_STRING'
         62        ASSIGN                                                   !7, ~50
   57    63        FETCH_R                      global              ~52     '_SERVER'
         64        FETCH_DIM_R                                      ~53     ~52, 'HOST_NAME'
         65        CONCAT                                           ~54     '+%28Called+URL%3A+', ~53
         66        FETCH_R                      global              ~55     '_SERVER'
         67        FETCH_DIM_R                                      ~56     ~55, 'PHP_SELF'
         68        CONCAT                                           ~57     ~54, ~56
         69        ISSET_ISEMPTY_CV                                 ~58     !7
         70        BOOL_NOT                                         ~59     ~58
         71      > JMPZ                                                     ~59, ->75
         72    >   CONCAT                                           ~60     '%3F', !7
         73        QM_ASSIGN                                        ~61     ~60
         74      > JMP                                                      ->76
         75    >   QM_ASSIGN                                        ~61     ''
         76    >   CONCAT                                           ~62     ~57, ~61
         77        CONCAT                                           ~63     ~62, '%29'
         78        ASSIGN_OP                                     8          !5, ~63
   59    79        CONCAT                                           ~65     '%22', !0
         80        CONCAT                                           ~66     ~65, '%22+'
         81        CONCAT                                           ~67     ~66, !5
         82        ASSIGN                                                   !8, ~67
   61    83        FETCH_STATIC_PROP_W          unknown             $69     'errorArr'
         84        ASSIGN_DIM                                               $69
         85        OP_DATA                                                  !0
   63    86        BOOL_NOT                                         ~71     !2
         87      > JMPZ                                                     ~71, ->92
   64    88    >   INIT_FCALL                                               'trigger_error'
         89        SEND_VAR                                                 !8
         90        SEND_VAR                                                 !1
         91        DO_ICALL                                                 
   67    92    > > RETURN                                                   null

End of function throwerror

Function throwdeprecated:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mVhXG
function name:  throwDeprecated
number of ops:  8
compiled vars:  !0 = $suppress
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   RECV_INIT                                        !0      <false>
   72     1        INIT_STATIC_METHOD_CALL                                  'ErrorLog', 'throwError'
          2        SEND_VAL                                                 'Deprecated%21'
          3        SEND_VAL                                                 1024
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 2
          6        DO_FCALL                                      0          
   73     7      > RETURN                                                   null

End of function throwdeprecated

Function haserrors:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mVhXG
function name:  hasErrors
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E >   ISSET_ISEMPTY_STATIC_PROP                        ~0      'errorArr'
          1        BOOL_NOT                                         ~1      ~0
          2      > RETURN                                                   ~1
   78     3*     > RETURN                                                   null

End of function haserrors

Function getbacktrace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mVhXG
function name:  getBacktrace
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   82     0  E >   INIT_FCALL                                               'version_compare'
          1        SEND_VAL                                                 '8.0.0'
          2        SEND_VAL                                                 '5.2.5'
          3        SEND_VAL                                                 '%3C'
          4        DO_ICALL                                         $0      
          5      > JMPZ                                                     $0, ->10
   83     6    >   INIT_FCALL                                               'debug_backtrace'
          7        DO_ICALL                                         $1      
          8      > RETURN                                                   $1
          9*       JMP                                                      ->14
   85    10    >   INIT_FCALL                                               'debug_backtrace'
         11        SEND_VAL                                                 <false>
         12        DO_ICALL                                         $2      
         13      > RETURN                                                   $2
   87    14*     > RETURN                                                   null

End of function getbacktrace

End of class ErrorLog.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.72 ms | 1411 KiB | 24 Q