我可以让 xdebug 在出现异常时停止\中断吗?(Ubuntu/Netbeans IDE/PHP 5.4/CLI/xdebug)

iVe*_*nGO 5 php xdebug

我正在运行 PHP CLI 应用程序。

如果我设置了一个断点,xdebug 就会停止在该断点上。如果我写xdebug_break();它也会停止。

如果应用程序抛出异常,我可以让它停止吗?

我的ini文件:

php-i | grep php.ini 加载的配置文件 => /etc/php5/cli/php.ini

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
Run Code Online (Sandbox Code Playgroud)

小智 1

单独使用 xdebug 是不可能的,但是在 php 中,您可以使用 set_exception_handler 来注册一个捕获未捕获异常的函数。然后您可以在该函数中放置一个断点。

请参阅http://php.net/manual/en/function.set-exception-handler.php

您可以对错误执行相同的操作:

http://php.net/manual/en/function.set-error-handler.php