3v4l.org

run code in 300+ PHP versions simultaneously
<?php $error_handler = function($level,$message) { 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 $eh after log written // ... set_error_handler($this); 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/5UstZ
function name:  (null)
number of ops:  14
compiled vars:  !0 = $error_handler
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F5UstZ%3A3%240'
          1        ASSIGN                                                   !0, ~1
   21     2        INIT_FCALL                                               'set_error_handler'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   23     5        INIT_FCALL                                               'trigger_error'
          6        SEND_VAL                                                 'Some+message'
          7        SEND_VAL                                                 1024
          8        DO_ICALL                                                 
   27     9        INIT_FCALL                                               'trigger_error'
         10        SEND_VAL                                                 'Some+other+message'
         11        SEND_VAL                                                 1024
         12        DO_ICALL                                                 
   30    13      > RETURN                                                   1

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

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

Function %00%7Bclosure%7D%2Fin%2F5UstZ%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5UstZ
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%2F5UstZ%3A9%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.79 ms | 1400 KiB | 19 Q