Stack Traces and Arguments
By default, the stack traces PHP prints when an exception is
raised include information about the arguments passed to a function
or method. The zend.exception_ignore_args
configuration
option was introduced in PHP 7.4 for controlling whether or not
arguments should be included in these stack traces.
function f(int $x): void
{
throw new Exception;
}
f(1);
Executing the code shown above with PHP 7.3 and earlier prints the output shown below:
Fatal error: Uncaught Exception in example.php:4
Stack trace:
#0 example.php(7): f(1)
#1 {main}
thrown in example.php on line 4
The #0 example.php(7): f(1)
line is the interesting
one: f(1)
indicates that the exception was raised from
within the f
function when it was called with the
argument 1
.
Executing the same code with PHP 7.4 and the default setting of
zend.exception_ignore_args=0
prints the same output as
PHP 7.3 and earlier.
Executing the same code with PHP 7.4 and
zend.exception_ignore_args=1
prints the output shown
below:
Fatal error: Uncaught Exception in example.php:4
Stack trace:
#0 example.php(7): f()
#1 {main}
thrown in example.php on line 4
The argument f()
was called with is no longer shown
in the stack trace.