3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * driver.php * ---------- * Registers a shutdown-function, that includes "error_handler.php" (which merely defines * a innocuous function named "handle_error", and includes "throw_fatal_error.php" * (that provokes an error declaring two classes with the same name). * * What happens is that the fatal error is thrown, shutdownFunc() is called and * "error_handler.php" is included -- but it occurs another fatal error, complaining that * handle_error() (defined in "error_handler.php") is undefined. * The problem does not happen with classes, as can be demonstrated by ErrorClass, * which is defined in "error_handler.php" and it's existence checked on shutdownFunc(). * * VERY IMPORTANT NOTE * If "throw_fatal_error.php" does not include a namespace or if neither class inherits * from another, everything works ok! */ function shutdownFunc () { eval(<<<'PHP' function handle_error () { echo "handle_error() is here<br />\n"; } class ErrorClass extends \stdclass {} PHP ); echo "We're about to call <em>handle_error()</em>...<br />\n"; echo 'ErrorClass is ', class_exists ('ErrorClass') ? 'undefined' : 'defined', "<br />\n"; handle_error(); } register_shutdown_function ('shutdownFunc'); // Make sure errors are printed. ini_set ('display_errors', 'On'); // Include the file that provokes the error. eval(<<<'PHP' namespace test; class aclass {} class aclass extends \stdclass {} PHP );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EsDVZ
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   34     0  E >   INIT_FCALL                                                   'register_shutdown_function'
          1        SEND_VAL                                                     'shutdownFunc'
          2        DO_ICALL                                                     
   37     3        INIT_FCALL                                                   'ini_set'
          4        SEND_VAL                                                     'display_errors'
          5        SEND_VAL                                                     'On'
          6        DO_ICALL                                                     
   40     7        INCLUDE_OR_EVAL                                              'namespace+test%3B%0A%0Aclass+aclass+%7B%7D%0A%0Aclass+aclass+extends+%5Cstdclass+%7B%7D', EVAL
   46     8      > RETURN                                                       1

Function shutdownfunc:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EsDVZ
function name:  shutdownFunc
number of ops:  13
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   INCLUDE_OR_EVAL                                              'function+handle_error+%28%29+%7B%0A%09echo+%22handle_error%28%29+is+here%3Cbr+%2F%3E%5Cn%22%3B%0A%7D%0A%0A%0Aclass+ErrorClass+extends+%5Cstdclass+%7B%7D', EVAL
   29     1        ECHO                                                         'We%27re+about+to+call+%3Cem%3Ehandle_error%28%29%3C%2Fem%3E...%3Cbr+%2F%3E%0A'
   30     2        ECHO                                                         'ErrorClass+is+'
          3        FRAMELESS_ICALL_1                class_exists        ~1      'ErrorClass'
          4      > JMPZ                                                         ~1, ->7
          5    >   QM_ASSIGN                                            ~2      'undefined'
          6      > JMP                                                          ->8
          7    >   QM_ASSIGN                                            ~2      'defined'
          8    >   ECHO                                                         ~2
          9        ECHO                                                         '%3Cbr+%2F%3E%0A'
   31    10        INIT_FCALL_BY_NAME                                           'handle_error'
         11        DO_FCALL                                          0          
   32    12      > RETURN                                                       null

End of function shutdownfunc

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
156.92 ms | 2657 KiB | 16 Q