English 中文(简体)
PHP effeciency vs Rainbow?
原标题:PHP effeciency vs HTML?

我很想知道,什么似乎更有效率。 如果我需要使用,

ThisIsMySuperLongLineOfHTMLCodeThatIsRepeatedManyTimes

我的守则中有许多内容,更高效、更明智的服务器,能够实际建立类似的东西。

$repeat =  ThisIsMySuperLongLineOfHTMLCodeThatIsRepeatedManyTimes 

and then use

<?php echo $repeat; ?>

它的位置?

最佳回答

PHP将需要更长时间,因为它必须操作该代码,然后将它作为超文本(使用对应体)输出。 超文本将紧靠下页并显示其使用次数。

EDIT:与你一样,特别侧重于服务器而不是用户的速度。 其他答案是正确的,即使用购买力平价的档案规模较小。

问题回答

Define efficient. PHP processing slightly takes longer than straight HTML, even when both are run through the PHP parser. However, your code looks cleaner and is easier to manage, especially if you need to make changes to the line being repeated, the number of times it is repeated, or if it is repeated in disparate places. And it takes less space on the server, so the code may actually be slightly faster because of the excess hard drive read times, depending on just how many times that line is repeated.

纯html是实现这一目标的最有效途径。 php需要由服务器配置,因此,需要一些额外的程序才能发送给用户。 如果你不改变你的“费用”,你可以使用纯粹的html。 真心实意地认为你的“超长的直线......”太长了,因此,php或html会走许多时间。

Execution time? Not sure.

For repeating the string? PHP. (Saves on server space).

<?php
$string =  ThisIsMySuperLongLineOfHTMLCodeThatIsRepeatedManyTimes ;
for($i = 0; i < 10; $i++) {
    echo $string;
}

?>

Will use less space than "ThisIsMySuperLongLineOfHTMLCodeThatIsRepeatedManyTimesThisIsMySuperLongLineOfHTMLCodeThatIsRepeatedManyTimesThisIsMySuperLongLineOfHTMLCodeThatIsRepeatedManyTimesThisIsMySuperLongLineOfHTMLCodeThatIsRepeatedManyTimesThisIsMySuperLongLineOfHTMLCodeThatIsRepeatedManyTimes" etc ....





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签