当前位置:Gxlcms > PHP教程 > php代码错误检测与校验

php代码错误检测与校验

时间:2021-07-01 10:21:17 帮助过:127人阅读

php有哪几种错误提示

1.notice : 注意

2.waring : 警告 (推荐学习:PHP视频教程)

3.error : 错误

PHP中都有哪几种查错方法?

1、语法检查--php配置文件里,把错误显示选项都打开或者代码开始部分,加error_reporting(E_ALL)

2、逻辑检查--设置断点,在断点前写日志 error_logs($message);exit();

3、HTTP调试--用抓包工具或者firebugs工具跟踪代码运行的全过程

PHPCS是代码检测规范程度的工具

PHP代码规范有PSRs,为了能做到代码规范的自动化检查和修复,就需要用到PHPCS了。

常用命令

检查单个文件:phpcs /path/to/code

检查目录下的文件:phpcs /path/to/code/

查看已经安装的标准:phpcs -i

设置默认检查标准:phpcs --config-set default_standard /path/to/standard_file

查看配置:phpcs --config-show

指定报告格式:phpcs --report=summary /path/to/code ;可用的报告格式有full, xml, checkstyle, csv, json, emacs, source, summary, diff, svnblame, gitblame, hgblame, notifysend,默认为full

查看帮助:phpcs -h

自动修复:phpcbf /path/to/code

详细的使用说明见官方wiki

以上就是php代码错误检测与校验的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行