doupijin0397 2013-03-03 12:32
浏览 40
已采纳

PHP`-l`标志没有找到错误

Why might the PHP -l switch not find errors in test.html.

$ cat test.html 
<?php
error_reporting(E_ALL);
echo "Hello, world!";

sdfsdfsdfsdf

?>
$ php -dhtml_errors=0 -ddisplay_errors=On -l test.html 
No syntax errors detected in test.html
$ php test.html 
Hello, world!PHP Notice:  Use of undefined constant sdfsdfsdfsdf - assumed 'sdfsdfsdfsdf' in test.html on line 7
$ 

Other types of errors are also not found, such as undefined functions, require_once() to nonexistant files, incorrect syntax in array declarations, etc. Why might this be?

Thanks.

  • 写回答

2条回答 默认 最新

  • doudiza9154 2013-03-03 12:47
    关注

    -l Syntax check only (lint)

    -l performs a static syntax check. The code is never actually executed. And in your code there are no syntax errors.

    The gibberish at the end of your file is considered a constant (since it's a valid name for a constant) and undefined constants evaluate to their string representation (and cause an E_NOTICE). Since it's the last statement in the file the missing semicolon also does not result in a syntax error.

    Since PHP is a dynamic language an undefined constant cannot be detected without executing the code - define() is just a normal function after all.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题