PHP编码的不同方法的速度 [英] Speed of different approaches to php coding

查看:69
本文介绍了PHP编码的不同方法的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


想知道是否有人知道哪些通常更快:


1)写大部分html代码并插入<? php ...?>需要时。


2)写作主要是<?php?>并使用echo来打印东西,即使它主要是HTML。


我有什么方法可以自己测试一下吗?


谢谢,

Hi all,

Wondering if someone knew which is normally quicker:

1) Writing mostly html code and inserting <?php ... ?> when required.

2) Writing mostly <?php ?> and using echo to print stuff, even when it''s mostly html.

And is there some way I can test this for myself?

Thanks,

推荐答案

我从不关心这个。我只是一个懒惰的程序员。如果<?php标签启动,我继续使用echo打印,直到我真的需要关闭php标签。

如果格式在<?php?>之外看起来不错标签,我给小一个变量回声。
I never cared for this. Just a lazy programmer I am. If <?php tag is started, I continue using echo to print until I really need to close the php tag.
If formatting is looking good outside the <?php ?> tags, I give small one variable echos.



我从来不关心这个。我只是一个懒惰的程序员。如果<?php标签启动,我继续使用echo打印,直到我真的需要关闭php标签。

如果格式在<?php?>之外看起来不错标签,我给小一个变量回声。
I never cared for this. Just a lazy programmer I am. If <?php tag is started, I continue using echo to print until I really need to close the php tag.
If formatting is looking good outside the <?php ?> tags, I give small one variable echos.



是的我知道你的意思。其中一个半打6个。但我想也许有一些PHP函数可能使我能够比较使用不同方法编写的2个页面。

Yes I know what you mean. 6 of one and half a dozen of the other. But I thought maybe there was some php function maybe which might enable me to compare 2 pages written using the different methods.


如果你有大量的echo语句,它可以减慢速度,但在大多数情况下,你永远无法区分它们。对于显示效果的大型回声声明,它必须非常大*!


如果你想测试它,我会感兴趣:


制作两个相同的页面,包含大量的html。

大约一个放置:

[PHP]<?php echo<<< END

{html到这里}

END; [/ PHP]


这将测试一个大的声明会减慢它的速度下。为了测试很多小的回声,只需要在所有东西周围放置大量的回声({html})。


计时时要记住两件事。在阅读之前至少加载一次页面,因为可能有CSS或要下载的东西。我在我的FireFox中使用FireBug插件,并且有一个用于页面加载的计时器。第二件事是得到至少10个读数并取平均值因为加载时间会有所不同。


如果你让它工作我真的很感兴趣,所以请告诉我们。

但是对于OP来说,除非你有一个非常大的页面,否则你应该看不出太大的区别!
If you have a large amount of echo statements it can slow things down, but in most cases you will never be able to tell the difference. For a large echo statement to show an effect, it has to be really *huge*!

If you want to test it, and I would be interested:

Make two identical pages with lots of html.
Around one put:
[PHP]<?php echo <<<END
{html goes here}
END;[/PHP]

That will test how much a big statement will slow it down. To test a lot of small echos just put tonnes of echo(" {html} ") things around everything.

Two things to remember when timing. Load the page atleast once before you take a reading because there might be CSS or something to download. I use FireBug addon to my FireFox, and that has a timer for page loading. The second thing is get atleast 10 readings and average them because the load time will vary.

I''m really interested if you get it working, so let us know.
To the OP though, you shouldn''t see much difference unless you have a really big page!


这篇关于PHP编码的不同方法的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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