如果我们在代码文件中添加太多的注释,PHP会变慢吗? [英] Will PHP be slower if we add too many comments in code files?

查看:181
本文介绍了如果我们在代码文件中添加太多的注释,PHP会变慢吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

评论解释的代码和性能

在PHP中包含文件时,注释会有影响吗?





说我们有100个类文件,并且每当请求页面时,所有这些类都必须由PHP解析。

Let's say we have 100 class files and everytime when a page is requested, all these classes must be parsed by PHP.

如果几乎​​一半的源代码行是评论?因为通常我添加了很多评论&描述到代码。这对编译器没有关系coz注释没有编译,但是PHP是解释器,任何坏事可能发生?

Will PHP be slower if almost 1 half of the source code lines are the comments? Because usually I add a lot of comments & descriptions to code. This doesn't matter to compilers coz comments are not compiled, but PHP is interpreter, any bad thing may happen?

推荐答案

是,但它是最小的,这可以(应该)完全通过使用APC或另一个操作码缓存来解决。

Yes, but it's minimal, and this can (and should) be addressed entirely by using APC or another opcode cache. As a bonus, APC will speed everything else up as well.

如果您的网站运行缓慢,评论的原因。

If your site is slow, comments are not the reason.

这篇关于如果我们在代码文件中添加太多的注释,PHP会变慢吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆