3v4l.org

run code in 300+ PHP versions simultaneously
<?php set_error_handler(function (int $no, string $str): bool { var_dump('DEBUG: ' . $str); global $level; if ($level !== null) { error_reporting($level); // restore error level unset($level); return true; // handle the internal/helper error } // supress the current error output $level = error_reporting(); error_reporting(0); trigger_error('internal'); // trigger internal/helper error to restore the error level return false; // not handled to set the error_get_last() }); error_reporting(E_ALL); // to show the error, has no effect if the handler is called or not (expected, documented) var_dump(error_reporting()); trigger_error('custom'); // trigger_error('internal2'); // uncomment to reproduce the desired behaviour var_dump(error_get_last()['message']); var_dump(error_reporting());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kS1vM
function name:  (null)
number of ops:  27
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'set_error_handler'
          1        DECLARE_LAMBDA_FUNCTION                          ~0      [0]
   21     2        SEND_VAL                                                 ~0
    3     3        DO_ICALL                                                 
   23     4        INIT_FCALL                                               'error_reporting'
          5        SEND_VAL                                                 32767
          6        DO_ICALL                                                 
   24     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'error_reporting'
          9        DO_ICALL                                         $3      
         10        SEND_VAR                                                 $3
         11        DO_ICALL                                                 
   25    12        INIT_FCALL                                               'trigger_error'
         13        SEND_VAL                                                 'custom'
         14        DO_ICALL                                                 
   27    15        INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'error_get_last'
         17        DO_ICALL                                         $6      
         18        FETCH_DIM_R                                      ~7      $6, 'message'
         19        SEND_VAL                                                 ~7
         20        DO_ICALL                                                 
   28    21        INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'error_reporting'
         23        DO_ICALL                                         $9      
         24        SEND_VAR                                                 $9
         25        DO_ICALL                                                 
         26      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kS1vM
function name:  {closure}
number of ops:  26
compiled vars:  !0 = $no, !1 = $str, !2 = $level
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'var_dump'
          3        CONCAT                                           ~3      'DEBUG%3A+', !1
          4        SEND_VAL                                                 ~3
          5        DO_ICALL                                                 
    6     6        BIND_GLOBAL                                              !2, 'level'
    7     7        TYPE_CHECK                                  1020          !2
          8      > JMPZ                                                     ~5, ->14
    8     9    >   INIT_FCALL                                               'error_reporting'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
    9    12        UNSET_CV                                                 !2
   11    13      > RETURN                                                   <true>
   15    14    >   INIT_FCALL                                               'error_reporting'
         15        DO_ICALL                                         $7      
         16        ASSIGN                                                   !2, $7
   16    17        INIT_FCALL                                               'error_reporting'
         18        SEND_VAL                                                 0
         19        DO_ICALL                                                 
   18    20        INIT_FCALL                                               'trigger_error'
         21        SEND_VAL                                                 'internal'
         22        DO_ICALL                                                 
   20    23      > RETURN                                                   <false>
   21    24*       VERIFY_RETURN_TYPE                                       
         25*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.91 ms | 1007 KiB | 18 Q