我很想知道,什么似乎更有效率。 如果我需要使用,
ThisIsMySuperLongLineOfHTMLCodeThatIsRepeatedManyTimes
我的守则中有许多内容,更高效、更明智的服务器,能够实际建立类似的东西。
$repeat = ThisIsMySuperLongLineOfHTMLCodeThatIsRepeatedManyTimes
and then use
<?php echo $repeat; ?>
它的位置?
我很想知道,什么似乎更有效率。 如果我需要使用,
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 ....
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 ...
<?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 = ...
I found this script online that creates a thumbnail out of a image but the thumbnail image is created with poor quality how can I improve the quality of the image. And is there a better way to create ...
如何确认来自正确来源的数字。
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 ...
I wonder there is a way to post a message to a facebook business page with cURL? thanks
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? 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 ...