3v4l.org

run code in 300+ PHP versions simultaneously
<?php $error_handler = function($level,$message) use (&$error_handler) { echo "Main error handler: $message \n"; // ... // imagine somewhere inside the error handler a log writer is called // which uses it's own error handler for failing file operations // which is what Zend\Log\Writer\Stream does with Zend\StdLib\ErrorHandler $nested_error_handler = function ($level,$message) { echo "Nested error handler: $message \n"; }; set_error_handler($nested_error_handler,E_WARNING); //strpos(); //Produce a warning inside the log writer restore_error_handler(); //restore the error handler to $error_handler after log written // ... set_error_handler($error_handler); return true; }; set_error_handler($error_handler); trigger_error('Some message',E_USER_NOTICE); /* expected output: Main error handler: Some message */ trigger_error('Some other message',E_USER_NOTICE); /* expected output: Main error handler: Some other message */
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YijHT
function name:  (null)
number of ops:  15
compiled vars:  !0 = $error_handler
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FYijHT%3A3%240'
          1        BIND_LEXICAL                                             ~1, !0
          2        ASSIGN                                                   !0, ~1
   21     3        INIT_FCALL                                               'set_error_handler'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
   23     6        INIT_FCALL                                               'trigger_error'
          7        SEND_VAL                                                 'Some+message'
          8        SEND_VAL                                                 1024
          9        DO_ICALL                                                 
   27    10        INIT_FCALL                                               'trigger_error'
         11        SEND_VAL                                                 'Some+other+message'
         12        SEND_VAL                                                 1024
         13        DO_ICALL                                                 
   30    14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FYijHT%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YijHT
function name:  {closure}
number of ops:  20
compiled vars:  !0 = $level, !1 = $message, !2 = $error_handler, !3 = $nested_error_handler
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    4     3        ROPE_INIT                                     3  ~5      'Main+error+handler%3A+'
          4        ROPE_ADD                                      1  ~5      ~5, !1
          5        ROPE_END                                      2  ~4      ~5, '+%0A'
          6        ECHO                                                     ~4
    9     7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FYijHT%3A9%241'
          8        ASSIGN                                                   !3, ~7
   12     9        INIT_FCALL                                               'set_error_handler'
         10        SEND_VAR                                                 !3
         11        SEND_VAL                                                 2
         12        DO_ICALL                                                 
   14    13        INIT_FCALL                                               'restore_error_handler'
         14        DO_ICALL                                                 
   16    15        INIT_FCALL                                               'set_error_handler'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
   18    18      > RETURN                                                   <true>
   19    19*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FYijHT%3A3%240

Function %00%7Bclosure%7D%2Fin%2FYijHT%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YijHT
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $level, !1 = $message
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        ROPE_INIT                                     3  ~3      'Nested+error+handler%3A+'
          3        ROPE_ADD                                      1  ~3      ~3, !1
          4        ROPE_END                                      2  ~2      ~3, '+%0A'
          5        ECHO                                                     ~2
   11     6      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FYijHT%3A9%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.88 ms | 1400 KiB | 19 Q