PHP:我得到一个完全空白的页面,我不知道如何在 PHP 中调试它

2022-01-25 00:00:00 include php fatal-error

我在 php 中调试时遇到了一些问题.当我包含这一行时:

I'm having some issues to debug this in php. When I include this line:

require_once("http://" . $_SERVER["HTTP_HOST"] . "/dompdf/dompdf_config.inc.php");

我得到的只是一个空白页面,我没有得到任何 html 代码作为响应.也许错误消息被隐藏了?

what I get is just a blank page, I don't get any html code as response. Maybe the error messages are hidden ?

推荐答案

您不应该像这样要求/包含远程文件.而是提供本地绝对或相对路径.

You should not require/include a remote file like this. Instead provide the local absolute or relative path.

虽然不安全且不推荐,但如果设置了某些配置选项,从技术上讲是可行的.(allow_url_include)

Though insecure and not recommended, it is technically possible to do if certain configuration options are set. (allow_url_include)

请参阅下面有关 display_errors 的其他答案,以了解未来的调试问题.我经常使用 PHP 命令行解释器来获取真正的错误,而不允许将错误详细信息呈现给 Web 访问者.

See other answers below regarding display_errors for future debugging concerns. I often use the PHP command line interpreter to get the real error, without allowing error details to be presented to web visitors.

相关文章