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. 虽然并非每种情况都匹配。 Yet there are some general steps to solve syntax mistakes . 但是,有一些常规步骤可以解决语法错误 This references summarized the common pitfalls: 这些参考文献总结了常见的陷阱:

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值