apache - How is the wrong PHP file catching an exception? -


i don't know how code index.php catching exception when go temp.php in browser. not duplicate on newly created local site (apache 2), may existing local site or apache setup, or maybe i'm overlooking simple.

temp.php:

<?php  try {     throw new \exception('temp exception message'); } catch (exception $e) {     die('temp catch die');     error_log("[".date('y-m-d h:i:s e')."] ".$e->getmessage(). "\n\n", 3, '/media/gcat/storage/it-all.com/software/projectssrc/spaghettify/storage/logs/phperrors.log'); } die('temp end die'); 

index.php:

<?php //declare(strict_types=1); try {     throw new \exception('index exception message'); } catch (exception $e) {     echo 'catch index';     error_log("[".date('y-m-d h:i:s e')."] ".$e->getmessage(). "\n\n", 3, '/media/gcat/storage/it-all.com/software/projectssrc/spaghettify/storage/logs/phperrors.log'); } die('index end die'); 

when go temp.php in browser, output "temp catch die" error log shows "index exception message".

die() same exit(). both stop script execution.

the call error_log() in temp.php never executed. line see in log file generated call error_log() in index.php (when load index.php in browser).


if don't load index.php in browser error line still appears in log file, chances have rewrite rules in .htaccess route requests non-existent paths index.php. (most php frameworks use such rules handle seo-friendly urls). when load temp.php in browser, browser requests /favicon.ico; apache cannot find , because of rewrite rules loads index.php instead.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -