如何调试PHP脚本?

如何调试PHP脚本?

如何调试?PHP剧本?

我知道基本的调试,例如使用错误报告。中的断点调试PHPEcli启示也很有用。

什么是最佳在phpStorm或任何其他IDE中调试的方法?


慕田峪4524236
浏览 568回答 3
3回答

慕码人8056858

试一试日蚀PDT若要设置具有您前面提到的调试功能的Eclipse环境,请执行以下操作。进入代码的能力是一种比以前的var_dump方法更好的调试方法,它可以在不同的点上打印,查看流程出错的地方。当其他一切都失败了,而我所拥有的只有SSH和VIM时,我仍然var_dump()/die()找出密码向南的方向。

HUH函数

您可以在与javascript相同的环境中使用Firephp作为Firebug的外接程序来调试php。我也用XDEBUG前面提到的用来分析php的。

呼啦一阵风

这是我的小型调试环境:error_reporting(-1);assert_options(ASSERT_ACTIVE,&nbsp;1);assert_options(ASSERT_WARNING,&nbsp;0);assert_options(ASSERT_BAIL,&nbsp;0); assert_options(ASSERT_QUIET_EVAL,&nbsp;0);assert_options(ASSERT_CALLBACK,&nbsp;'assert_callcack');set_error_handler('error_handler'); set_exception_handler('exception_handler');register_shutdown_function('shutdown_handler'); function&nbsp;assert_callcack($file,&nbsp;$line,&nbsp;$message)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;Customizable_Exception($message,&nbsp;null,&nbsp;$file,&nbsp;$line);}function&nbsp;error_handler($errno,&nbsp;$error,&nbsp;$file,&nbsp;$line,&nbsp;$vars)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($errno&nbsp;===&nbsp;0&nbsp;||&nbsp;($errno&nbsp;&&nbsp;error_reporting())&nbsp;===&nbsp;0)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return; &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;Customizable_Exception($error,&nbsp;$errno,&nbsp;$file,&nbsp;$line);}function&nbsp;exception_handler(Exception&nbsp;$e)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Do&nbsp;what&nbsp;ever! &nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;'<pre>',&nbsp;print_r($e,&nbsp;true),&nbsp;'</pre>'; &nbsp;&nbsp;&nbsp;&nbsp;exit;}function&nbsp;shutdown_handler()&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(null&nbsp;!==&nbsp;$error&nbsp;=&nbsp;error_get_last())&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;Customizable_Exception($error['message'],&nbsp;$error['type'],&nbsp;$error['file'],&nbsp;$error['line']); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;catch&nbsp;(Exception&nbsp;$e)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exception_handler($e); &nbsp;&nbsp;&nbsp;&nbsp;}}class&nbsp;Customizable_Exception&nbsp;extends&nbsp;Exception&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;__construct($message&nbsp;=&nbsp;null,&nbsp;$code&nbsp;=&nbsp;null,&nbsp;$file&nbsp;=&nbsp;null,&nbsp;$line&nbsp;=&nbsp;null)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($code&nbsp;===&nbsp;null)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent::__construct($message); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent::__construct($message,&nbsp;$code); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($file&nbsp;!==&nbsp;null)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->file&nbsp;=&nbsp;$file; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($line&nbsp;!==&nbsp;null)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->line&nbsp;=&nbsp;$line; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;}}
打开App,查看更多内容
随时随地看视频慕课网APP