doufuxi7093 2017-10-25 17:13
浏览 90
已采纳

更多的空格或更多标签需要更多的解释时间吗? [重复]

This question already has an answer here:

In PHP or Python (or whatever) the interpreter read the program line by line. So if I put a lot of linebreaks or empty lines, does the code need more interpreting time to execute? (Since it reads the whole bunch of my bad written code).

What about whitespaces and tabs? Does it matter?

I think more white space and more tabs mean more bytes, more long file size, more time to read the file.

Does it mean more time to read/process the source by the interpreter?

</div>
  • 写回答

1条回答 默认 最新

  • duanchongchu5177 2017-10-25 17:25
    关注

    According to author David Sklar in Learning PHP 5:

    You can put as many blank lines between statements as you want. The PHP interpreter ignores them. The semicolon tells the interpreter that one statement is over and another is about to begin. No whitespace at all or lots and lots of whitespace between statements doesn't affect the program's execution. (Whitespace is programmer-speak for blank-looking characters such as space, tab, and newline.)

    In practice, it's good style to put one statement on a line and to put blank lines between statements only when it improves the readability of your source code...

    So, feel free to use blank space and tabs to format your PHP code so that it is legible.

    Python is different from PHP and there are specific guidelines about how to format your code with blank space; see here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改