如何调试PHP脚本?如何调试?PHP剧本?我知道基本的调试,例如使用错误报告。中的断点调试PHPEcli启示也很有用。什么是最佳在phpStorm或任何其他IDE中调试的方法?
3 回答
慕码人8056858
TA贡献1803条经验 获得超6个赞
var_dump()/die()
呼啦一阵风
TA贡献1802条经验 获得超6个赞
error_reporting(-1);assert_options(ASSERT_ACTIVE, 1);assert_options(ASSERT_WARNING, 0);assert_options(ASSERT_BAIL, 0);
assert_options(ASSERT_QUIET_EVAL, 0);assert_options(ASSERT_CALLBACK, 'assert_callcack');set_error_handler('error_handler');
set_exception_handler('exception_handler');register_shutdown_function('shutdown_handler');
function assert_callcack($file, $line, $message) {
throw new Customizable_Exception($message, null, $file, $line);}function error_handler($errno, $error, $file, $line, $vars) {
if ($errno === 0 || ($errno & error_reporting()) === 0) {
return;
}
throw new Customizable_Exception($error, $errno, $file, $line);}function exception_handler(Exception $e) {
// Do what ever!
echo '<pre>', print_r($e, true), '</pre>';
exit;}function shutdown_handler() {
try {
if (null !== $error = error_get_last()) {
throw new Customizable_Exception($error['message'], $error['type'], $error['file'], $error['line']);
}
} catch (Exception $e) {
exception_handler($e);
}}class Customizable_Exception extends Exception {
public function __construct($message = null, $code = null, $file = null, $line = null) {
if ($code === null) {
parent::__construct($message);
} else {
parent::__construct($message, $code);
}
if ($file !== null) {
$this->file = $file;
}
if ($line !== null) {
$this->line = $line;
}
}}- 3 回答
- 0 关注
- 634 浏览
添加回答
举报
0/150
提交
取消
