Re: [PHP] PHP Error logs - no file-name

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 error

I'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: Online PHP editor | output for aqgb9 )

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 PHP: Runtime Configuration - Manual