PHP意外的T_LNUMBER如何解决,PHP解析/语法错误; 以及如何解决它们? - PHP parse/syntax errors; and how to solve them?...

问题:

Everyone runs into syntax errors. 每个人都遇到语法错误。 Even experienced programmers make typos. 即使是经验丰富的程序员也会打错字。 For newcomers, it's just part of the learning process. 对于新手来说,这只是学习过程的一部分。 However, it's often easy to interpret error messages such as: 但是,通常很容易解释以下错误消息:

PHP Parse error: syntax error, unexpected '{' in index.php on line 20 PHP解析错误:语法错误,第20行的index.php中出现意外的'{'

The unexpected symbol isn't always the real culprit. 意外的符号并不总是真正的罪魁祸首。 But the line number gives a rough idea of where to start looking. 但是行号给出了从哪里开始寻找的粗略想法。

Always look at the code context . 始终查看代码上下文 。 The syntax mistake often hides in the mentioned or in previous code lines . 语法错误通常隐藏在提到的代码行 或 以前的代码行中 。 Compare your code against syntax examples from the manual. 将代码与手册中的语法示例进行比较。

While not every case matches the other. 虽然并非每种情况都匹配。 This references summarized the common pitfalls: 这些参考文献总结了常见的陷阱:

Closely related references: 密切相关的参考文献:

And: 和:

While Stack Overflow is also welcoming rookie coders, it's mostly targetted at professional programming questions. 尽管Stack Overflow也欢迎新手程序员,但它主要针对专业编程问题。

Answering everyone's coding mistakes and narrow typos is considered mostly off-topic. 回答每个人的编码错误和狭窄的拼写错误通常被认为是题外话。

So please take the time to follow the basic steps , before posting syntax fixing requests. 因此,请花一些时间遵循基本步骤 ,然后再发布语法修复请求。

If you still have to, please show your own solving initiative, attempted fixes, and your thought process on what looks or might be wrong. 如果仍然需要,请展示您自己的解决方案,尝试的解决方案以及您对外观或错误之处的思考过程。

If your browser displays error messages such as "SyntaxError: illegal character", then it's not actually php -related, but a javascript - syntax error . 如果您的浏览器显示诸如“ SyntaxError:非法字符”之类的错误消息,则实际上与php相关,而不是与javascript相关的语法错误 。

Syntax errors raised on vendor code: Finally, consider that if the syntax error was not raised by editing your codebase, but after an external vendor package install or upgrade, it could be due to PHP version incompatibility, so check vendor's requirements against your platform setup. 供应商代码上引发的语法错误:最后,请考虑如果语法错误不是由于编辑代码库而引起的,而是在外部供应商软件包安装或升级后出现的,则可能是由于PHP版本不兼容所致,因此请针对平台设置检查供应商的要求。

解决方案:参考一:

https://stackoom.com/question/1DjeB/PHP解析-语法错误-以及如何解决它们

参考二:

https://oldbug.net/q/1DjeB/PHP-parse-syntax-errors-and-how-to-solve-them

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值