【问题标题】:Why does Xdebug throw an error for a file that's included, not required为什么 Xdebug 会为包含的文件引发错误,而不是必需的
【发布时间】:2010-10-22 09:49:30
【问题描述】:

我在 Ubuntu 9.04(桌面版)上运行 LAMP 服务器。我对 Ubuntu 很陌生,所以我通过 Synaptic 数据包管理器完成了大部分工作。然后我删除了 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 会为我提供错误报告。有人知道怎么帮忙吗?

【问题讨论】:

  • 您确定错误不是由于您传递给它的字符串没有引号引起的吗?我不记得那个错误是什么“级别”,但它可能是一个警告......

标签: php ubuntu include xdebug ubuntu-9.04


【解决方案1】:

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

德里克

【讨论】:

  • 是的,但是看看我的 error_reporting。我已将其设置为不显示警告。
  • 除非我读错了,否则你可以不显示通知,而不是警告。因此,警告是有效的。
【解决方案2】:

它应该抛出一个警告,而 require_once 抛出一个致命的。

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

@include_once('something.php');

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

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

【讨论】:

  • 哦,文件不存在,我知道这是事实。问题是,即使我的 php.ini 文件将错误报告设置为不显示通知,我也会收到警告...还是我忘记了什么?
【解决方案3】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-08
    • 2014-01-04
    • 2013-04-04
    • 2014-12-11
    • 1970-01-01
    相关资源
    最近更新 更多