3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ErrorLog { 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"] . "."; } } $out = "\"" . $err . "\" " . $info; if (!$suppress) { trigger_error($out, $level); } } function throwDeprecated ($suppress = false) { // Call this method from INSIDE a deprecated function, ErrorLog::throwError("Deprecated!", E_USER_NOTICE, $suppress, 2); } 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/8gICd
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   78     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/8gICd
function name:  a
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   75     0  E >   INIT_STATIC_METHOD_CALL                                  'ErrorLog', 'throwDeprecated'
          1        DO_FCALL                                      0          
   76     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 = 66, Position 2 = 70
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
Branch analysis from position: 48
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 70
Branch analysis from position: 66
Branch analysis from position: 70
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/8gICd
function name:  throwError
number of ops:  71
compiled vars:  !0 = $err, !1 = $level, !2 = $suppress, !3 = $shiftBack, !4 = $trace, !5 = $info, !6 = $caller, !7 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <const ast>
          2        RECV_INIT                                        !2      <false>
          3        RECV_INIT                                        !3      1
   10     4        INIT_FCALL                                               'str_replace'
   12     5        SEND_VAL                                                 <array>
   15     6        SEND_VAL                                                 <array>
   17     7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
   20     9        INIT_STATIC_METHOD_CALL                                  'ErrorLog', 'getBacktrace'
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !4, $9
   22    12        ASSIGN                                                   !5, ''
   24    13        ISSET_ISEMPTY_CV                                 ~12     !4
         14        BOOL_NOT                                         ~13     ~12
         15      > JMPZ                                                     ~13, ->60
   25    16    > > JMP                                                      ->21
   26    17    >   INIT_FCALL                                               'array_shift'
         18        SEND_REF                                                 !4
         19        DO_ICALL                                                 
   27    20        PRE_DEC                                                  !3
   25    21    >   IS_SMALLER                                               0, !3
         22      > JMPNZ                                                    ~16, ->17
   31    23    >   FETCH_DIM_R                                      ~17     !4, 0
         24        FETCH_DIM_R                                      ~18     ~17, 'file'
         25        CONCAT                                           ~19     'in+', ~18
         26        CONCAT                                           ~20     ~19, '%3A'
         27        FETCH_DIM_R                                      ~21     !4, 0
         28        FETCH_DIM_R                                      ~22     ~21, 'line'
         29        CONCAT                                           ~23     ~20, ~22
         30        CONCAT                                           ~24     ~23, '.'
         31        ASSIGN_OP                                     8          !5, ~24
   34    32        COUNT                                            ~26     !4
         33        IS_SMALLER                                               1, ~26
         34      > JMPZ                                                     ~27, ->60
   35    35    >   INIT_FCALL                                               'array_shift'
         36        SEND_REF                                                 !4
         37        DO_ICALL                                                 
   36    38        FETCH_DIM_R                                      ~29     !4, 0
         39        ASSIGN                                                   !6, ~29
   38    40        ASSIGN_OP                                     8          !5, '+Thrown+by+'
   39    41        ISSET_ISEMPTY_DIM_OBJ                         0          !6, 'function'
         42      > JMPZ                                                     ~32, ->52
   40    43    >   ISSET_ISEMPTY_DIM_OBJ                         0          !6, 'class'
         44      > JMPZ                                                     ~33, ->48
   41    45    >   FETCH_DIM_R                                      ~34     !6, 'class'
         46        CONCAT                                           ~35     ~34, '%3A%3A'
         47        ASSIGN_OP                                     8          !5, ~35
   43    48    >   FETCH_DIM_R                                      ~37     !6, 'function'
         49        CONCAT                                           ~38     ~37, '%28%29+'
         50        ASSIGN_OP                                     8          !5, ~38
         51      > JMP                                                      ->53
   45    52    >   ASSIGN_OP                                     8          !5, 'global+scope+'
   47    53    >   FETCH_DIM_R                                      ~41     !6, 'file'
         54        CONCAT                                           ~42     'which+was+called+in+', ~41
         55        CONCAT                                           ~43     ~42, '%3A'
         56        FETCH_DIM_R                                      ~44     !6, 'line'
         57        CONCAT                                           ~45     ~43, ~44
         58        CONCAT                                           ~46     ~45, '.'
         59        ASSIGN_OP                                     8          !5, ~46
   51    60    >   CONCAT                                           ~48     '%22', !0
         61        CONCAT                                           ~49     ~48, '%22+'
         62        CONCAT                                           ~50     ~49, !5
         63        ASSIGN                                                   !7, ~50
   53    64        BOOL_NOT                                         ~52     !2
         65      > JMPZ                                                     ~52, ->70
   54    66    >   INIT_FCALL                                               'trigger_error'
         67        SEND_VAR                                                 !7
         68        SEND_VAR                                                 !1
         69        DO_ICALL                                                 
   57    70    > > 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/8gICd
function name:  throwDeprecated
number of ops:  8
compiled vars:  !0 = $suppress
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   RECV_INIT                                        !0      <false>
   61     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          
   62     7      > RETURN                                                   null

End of function throwdeprecated

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/8gICd
function name:  getBacktrace
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   65     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
   66     6    >   INIT_FCALL                                               'debug_backtrace'
          7        DO_ICALL                                         $1      
          8      > RETURN                                                   $1
          9*       JMP                                                      ->14
   68    10    >   INIT_FCALL                                               'debug_backtrace'
         11        SEND_VAL                                                 <false>
         12        DO_ICALL                                         $2      
         13      > RETURN                                                   $2
   70    14*     > RETURN                                                   null

End of function getbacktrace

End of class ErrorLog.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.53 ms | 1407 KiB | 24 Q