为什么 Xdebug 会对包含但不需要的文件抛出错误

发布于 2024-07-18 08:06:25 字数 1299 浏览 3 评论 0原文

我在 Ubuntu 9.04(桌面版)上运行 LAMP 服务器。 我对 Ubuntu 很陌生,所以我通过 Synaptic Packet Manager 完成了大部分工作。 然后我删除了 php5-common 并通过以下方式安装了 php5:apt-get install php5
我的错误报告设置为:error_reporting = E_ALL & ~E_NOTICE

我安装了 Xdebug 并将以下内容插入到我的 php.ini 文件中。

zend_extension=/usr/lib/php5/20060613/xdebug.so

[debug]
; Remote settings
xdebug.remote_autostart=off
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000

; General
xdebug.auto_trace=off
xdebug.collect_includes=on
xdebug.collect_params=off
xdebug.collect_return=on
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=http://www.php.net
xdebug.show_local_vars=0
xdebug.show_mem_delta=0
xdebug.max_nesting_level=100
;xdebug.idekey=

; Trace options
xdebug.trace_format=0
xdebug.trace_output_dir=/tmp
xdebug.trace_options=0
xdebug.trace_output_name=crc32

; Profiling
xdebug.profiler_append=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=crc32

现在,对于某个项目,我的页面中有以下代码行:

include_once(something.php);

现在,something.php 不存在。 因为它是包含的而不是必需的,所以我希望不会看到任何错误,但 XDebug 却给我生成了一个错误报告。 有人知道如何提供帮助吗?

I'm running LAMP server on Ubuntu 9.04(Desktop edition). I'm very new to Ubuntu, so I did most of this via the Synaptic Packet Manager. I then removed php5-common and just installed php5 via: apt-get install php5
My error reporting is set to: error_reporting = E_ALL & ~E_NOTICE

I installed Xdebug and inserted the following in my php.ini file.

zend_extension=/usr/lib/php5/20060613/xdebug.so

[debug]
; Remote settings
xdebug.remote_autostart=off
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000

; General
xdebug.auto_trace=off
xdebug.collect_includes=on
xdebug.collect_params=off
xdebug.collect_return=on
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=http://www.php.net
xdebug.show_local_vars=0
xdebug.show_mem_delta=0
xdebug.max_nesting_level=100
;xdebug.idekey=

; Trace options
xdebug.trace_format=0
xdebug.trace_output_dir=/tmp
xdebug.trace_options=0
xdebug.trace_output_name=crc32

; Profiling
xdebug.profiler_append=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=crc32

Now for a certain project, I have the following line of code in my pages:

include_once(something.php);

Now, something.php does not excist. Because it's included and not required, I expect to see no errors, yet XDebug makes me an error report. Does anybody know how to help?

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

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

发布评论

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

评论(3

凌乱心跳 2024-07-25 08:06:25

呃,这不是 Xdebug 改变的东西。 如果使用纯 PHP,您也会收到警告。

德里克

Uh, this is not something that Xdebug changes. You'd have gotten a warning with plain PHP as well.

Derick

厌倦 2024-07-25 08:06:25

它应该抛出一个警告,而 require_once 会抛出一个致命错误。

您可以通过以下方式解决这个问题:

@include_once('something.php');

但是,这是一种不好的做法。

另一种方法是显式检查文件是否存在,但除非您提取所有包含路径并检查每个文件中是否存在该文件,否则这将不起作用。

It should throw a warning, whereas require_once throws a fatal.

You can hack around this by doing:

@include_once('something.php');

However, that's kind of bad practice.

The alternative is to explicitly check if the file exists, but that won't work unless you extract all the include paths and check if the file exists in each.

氛圍 2024-07-25 08:06:25

我认为开箱即用的 xdebug 会比 php 显示更多错误,但这只是我的迷信。

有时,只有在满月时它才会抛出错误。

I think out of the box xdebug will show you more errors than php would, but that's just me being superstitous.

Sometimes it only throws an error when there's a full moon out, too.

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