PHP 异常堆栈跟踪中缺少函数参数
PHP missing function arguments in exception stack trace
我正在努力为我的 php 应用开发我自己的错误处理程序,我需要向开发服务器上的用户发送一个漂亮的异常报告。
因此,当它捕获异常时,它必须解析异常堆栈跟踪以显示函数、行参数等。
但是,我在函数调用中不再有参数。
我认为这是由 XDebug 引起的,我尝试更改 xdebug.collect_params 的值来修复它但没有成功。
实际上,此配置仅更改了现在具有函数调用参数的xdebug 默认报告的显示。
我做了一个测试脚本来测试一下,让你看看。
<?php
$config = 'xdebug.collect_params';
echo "Current value of $config is<br />\n";
var_dump(ini_get($config));
ini_set($config, 3);
function fallDeepToHell($param) {
echo 'Param is : ' . $param . "<br>\n";
throw new Exception();
}
try {
fallDeepToHell('from heaven');
} catch(Exception $e) {
var_dump($e->getTrace());
var_dump($e->getTraceAsString());
}
fallDeepToHell('from heaven');
我的开发服务器上的结果是
我正在使用 PHP 7.4 和 FPM。
我的 php.ini 变化:
max_execution_time = 30
memory_limit = 128M
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
html_errors = On
post_max_size = 100M
upload_max_filesize = 49M
date.timezone = Europe/Paris
;[mail function]
mail.add_x_header = On
;[Session]
session.gc_divisor = 1000
session.gc_maxlifetime = 43200
我的 XDebug 设置仅与远程相关。
我遇到了同样的问题,原来是新的 zend.exception_ignore_args
INI 指令 introduced in PHP 7.4.
zend.exception_ignore_args
is a new INI directive for including or
excluding arguments from stack traces generated from exceptions.
我正在努力为我的 php 应用开发我自己的错误处理程序,我需要向开发服务器上的用户发送一个漂亮的异常报告。 因此,当它捕获异常时,它必须解析异常堆栈跟踪以显示函数、行参数等。 但是,我在函数调用中不再有参数。
我认为这是由 XDebug 引起的,我尝试更改 xdebug.collect_params 的值来修复它但没有成功。 实际上,此配置仅更改了现在具有函数调用参数的xdebug 默认报告的显示。
我做了一个测试脚本来测试一下,让你看看。
<?php
$config = 'xdebug.collect_params';
echo "Current value of $config is<br />\n";
var_dump(ini_get($config));
ini_set($config, 3);
function fallDeepToHell($param) {
echo 'Param is : ' . $param . "<br>\n";
throw new Exception();
}
try {
fallDeepToHell('from heaven');
} catch(Exception $e) {
var_dump($e->getTrace());
var_dump($e->getTraceAsString());
}
fallDeepToHell('from heaven');
我的开发服务器上的结果是
我正在使用 PHP 7.4 和 FPM。
我的 php.ini 变化:
max_execution_time = 30
memory_limit = 128M
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
html_errors = On
post_max_size = 100M
upload_max_filesize = 49M
date.timezone = Europe/Paris
;[mail function]
mail.add_x_header = On
;[Session]
session.gc_divisor = 1000
session.gc_maxlifetime = 43200
我的 XDebug 设置仅与远程相关。
我遇到了同样的问题,原来是新的 zend.exception_ignore_args
INI 指令 introduced in PHP 7.4.
zend.exception_ignore_args
is a new INI directive for including or excluding arguments from stack traces generated from exceptions.