3v4l.org

run code in 300+ 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 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EsDVZ
function name:  shutdownFunc
number of ops:  15
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        INIT_FCALL                                               'class_exists'
          4        SEND_VAL                                                 'ErrorClass'
          5        DO_ICALL                                         $1      
          6      > JMPZ                                                     $1, ->9
          7    >   QM_ASSIGN                                        ~2      'undefined'
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~2      'defined'
         10    >   ECHO                                                     ~2
         11        ECHO                                                     '%3Cbr+%2F%3E%0A'
   31    12        INIT_FCALL_BY_NAME                                       'handle_error'
         13        DO_FCALL                                      0          
   32    14      > RETURN                                                   null

End of function shutdownfunc

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.15 ms | 1401 KiB | 19 Q