Re: PHP Error logs - no file-name
| From: | AllenJB | Date: | Sun, 25 Oct 2026 09:13:22 +0000 |
| Subject: | Re: PHP Error logs - no file-name | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-328888@lists.php.net to get a copy of this message | ||
On 2026-10-24 20:20, gordonisnz@gmail.com wrote:
PHP Error logs. Hello, ive noticed over the last several months - that if there is an error with a function name not found, yes - an error log appears.. HOWEVER - the name of the included file is never displayed in the errorI'm unable to reproduce this. Given test.php contains: <?php doesnotexist(); And test2.php contains: <?php include("test2.php"); Run the following command: php -d error_log="php.log" -d log_errors=1 -f test2.php After which php.log contains: [25-Oct-2026 08:56:54 UTC] PHP Fatal error: Uncaught Error: Call to undefined function doesnotexist() in /home/allenjb/tmp/test.php:3 Stack trace: #0 /home/allenjb/tmp/test2.php(2): include() #1 {main} thrown in /home/allenjb/tmp/test.php on line 3 The PHP file in which the error originates is displayed in both the error message line, and the strack trace. This test was performed in PHP 8.4.27 From 8.5 there's an ini setting for
fatal_error_backtraces that determines if the stack trace is included, but I don't believe this should affect logging of the error message (the first line in the example above)
Also - if i "include" a file - but the name of the filename or the path is wrong - there is no error... Is this deliberate ? (ive got the latest PHP now - with that recent bug story in the news - however ive been noticing this for a long time... ) I'd like to know if there is an error in the included file-name as well..
include, by design, issues a warning rather than an error if the referenced file doesn't exist. (See, for example: https://3v4l.org/aqgb9#v8.5.11 )
Check your error_reporting level, which defines the level or errors and warnings that are logged / displayed by PHP's built-in error reporting. This is primarily set in php.ini, but may be overridden in other configuration files like FPM pool configuration or at runtime with ini_set() or error_reporting().
If you want a fatal error to occur when a file is not found, use require instead of include
For settings related to PHP's built-in error reporting, see https://www.php.net/manual/en/errorfunc.configuration.php