展开 PHP 堆栈跟踪参数

发布于 2024-10-08 13:10:01 字数 204 浏览 0 评论 0原文

在从开发中的 PHP 应用程序返回的堆栈跟踪中,函数的长字符串参数在错误页面上显示时被截断:

Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO "tb...', Array)

如何扩展查询参数以使全文可见?服务器正在运行 PHP 5.3.3。

On a stack trace returned from a PHP application in development, long string arguments to a function are truncated when display on the error page:

Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO "tb...', Array)

How can I expand the query argument so the full text is visible? The server is running PHP 5.3.3.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

墨洒年华 2024-10-15 13:10:01

使用 debug_backtrace 代替。据我所知,它会给你完整的跟踪并且不会删除参数。

来摆脱它

try {
   ...
} catch (Throwable $e)
   // var_dump($e.$e->getTrace()); // for the local environment
   error_log($e.$e->getTrace()); // for the live environment
}

再考虑一下:您可以通过为整个应用程序添加全局 try catch或添加 全局异常处理程序到您的应用程序。

Use debug_backtrace instead. It will give you the whole trace and doesn't trim arguments as far as I know.

On a second thought: You might get away with it by either adding a global try catch for the entire application

try {
   ...
} catch (Throwable $e)
   // var_dump($e.$e->getTrace()); // for the local environment
   error_log($e.$e->getTrace()); // for the live environment
}

or by adding a global Exception handler to your application.

我乃一代侩神 2024-10-15 13:10:01

从 PHP 8.0 开始,实际上可以提高参数被截断的限制。

您可以更改新引入的 php.ini 设置 zend.exception_string_param_max_len 并将其设置为 0 到 1000000 之间的任何值,默认值为 15。

这仅影响使用 getTraceAsString() 或通过将异常转换为字符串(例如,通过打印它)。

更多信息请访问此处在相应的 RFC 中。

Starting with PHP 8.0 it is possible to actually raise the limit at which arguments will be truncated.

You can change the newly introduced php.ini setting zend.exception_string_param_max_len and set it to any value between 0 and 1000000, the default being 15.

This only affects stack traces generated using getTraceAsString() or by casting an exception to a string (e.g., by printing it).

More information is available here or in the corresponding RFC.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文