php语法检查的方法总结
网络编程 2021-07-04 23:24www.168986.cn编程入门
在本篇文章里长沙网络推广给大家分享了关于php语法检查的方法的知识点内容,有需要的朋友们学习下。
我们可以使用lint检查
用lint静态检查。
静态是一种只检查语法描述方法而不执行程序的方法。
此时使用lint命令。
※php_check_syntax这个语法检查函数已经被废止,所以不能使用。
然后准备实际出现错误的php文件。
lint_test.php
<?php echo "error"
它只是一个在屏幕上显示error的代码。
将lint_test.php移动到某个目录并发出以下命令。
php -l lint_test.php
执行结果
PHP Parse error: syntax error, unexpected end of file, expecting ',' or ';' in lint_test.php on line 2 Parse error: syntax error, unexpected end of file, expecting ',' or ';' in lint_test.php on line 2Errors parsing lint_test.php
syntax error=输出语法错误指示。
它还返回错误行数为line 2。
因为有unexpected end of file,是第2行没有“;”是原因。
那么,修改lint_test.php,再次执行lint命令。
<?php echo "error";
执行结果为:
No syntax errors detected in lint_test.php
显示没有语法错误。
使用xdebug动态检查语法错误
首先,启用xdebug。
①从狼蚁网站SEO优化的官方站点下载xdebug,并记下下载的.dll文件所在的本地环境的路径。
https://xdebug./download.php
② 将以下内容添加到php.ini中。
zend_extension = ①中记录的路径
②重启Web服务器(Apache等)
这样就完成了设置。
使用xdebug检查错误
我们运行上述使用的lint_test.php。
lint_test.php
<?php echo "error"
有一个错误,因为最后没有分号。
内容与执行lint时的内容相同,但附加了一些装饰以便于查看。
与lint的最大区别在于执行代码后出现的错误,因此可以说由于动态检查而出现错误。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程