Jump to content

Recommended Posts

Does the server need to do more processing if html is included inside php tags?....

 

<html>
<head>
<title></title>
</head>

<body>

<?php
echo '<table border="1">';
echo '<tr>';
echo     '<th>Firstname</th>';
echo     '<th>Lastname</th>';
echo '</tr>';

echo '<tr>';
echo     '<td>Firstname</td>';
echo     '<td>Lastname</td>';
echo '</tr>';
echo '</table>';
?>

</body>
</html>

 

....than if PHP tags are included inside html?

 

<html>
<head>
<title></title>
</head>

<body>
<table border="1">
<tr>
    <th>Firstname</th>
    <th>Lastname</th>
</tr>

<tr>
    <td><?php echo "Firstname" ?></td>
    <td><?php echo "Lastname" ?></td>
</tr>
</table>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/83733-processing-power/
Share on other sites

If you want to test it, use the microtime function....

 

 

<?php

function microtime_float()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}

?><html>
<head>
<title></title>
</head>

<body>

<?php
$start = microtime_float();

echo '<table border="1">';
echo '<tr>';
echo     '<th>Firstname</th>';
echo     '<th>Lastname</th>';
echo '</tr>';

echo '<tr>';
echo     '<td>Firstname</td>';
echo     '<td>Lastname</td>';
echo '</tr>';
echo '</table>';

echo "Rendered in " . (microtime_float() - $start) . " seconds";
?>

</body>
</html>

 

Do the same for your other example.

Link to comment
https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426012
Share on other sites

Do I just change:

 

echo '<table border="1">';
echo '<tr>';
echo     '<th>Firstname</th>';
echo     '<th>Lastname</th>';
echo '</tr>';

echo '<tr>';
echo     '<td>Firstname</td>';
echo     '<td>Lastname</td>';
echo '</tr>';
echo '</table>';

 

to this?

 

<table border="1">
<tr>
    <th>Firstname</th>
    <th>Lastname</th>
</tr>

<tr>
    <td><?php echo "Firstname" ?></td>
    <td><?php echo "Lastname" ?></td>
</tr>
</table>

Link to comment
https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426035
Share on other sites

the load time will change, depending on a lot of different things (server load primarily...especially with shared hosting).  You are also using a VERY small sample.  To get a really accurate number, use a larger set of code (using multiple echo statements will be slower than a single echo...), and perform the operation many times (> 1000) and get an average.

Link to comment
https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426053
Share on other sites

Well technically every php echo would be doing double the work, but not on your server

When you echo out something your server has to make that document the person requested reflect that text you are echoing.  When its in pure html the server ignores it as it only phrases in the

<?php or <?

?>

brackets so to answer your question the pure html with minimal php echoing is faster, however the variances wouldn't be in the miliseconds until say 1000+ echo statements or lines of text.

Microfloat might give you a small variences, but its Standard deviation of varience will be so high that you can consider it to all be networking noise.

Link to comment
https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426060
Share on other sites

Well technically every php echo would be doing double the work, but not on your server

When you echo out something your server has to make that document the person requested reflect that text you are echoing.  When its in pure html the server ignores it as it only phrases in the

<?php or <?

?>

brackets so to answer your question the pure html with minimal php echoing is faster, however the variances wouldn't be in the miliseconds until say 1000+ echo statements or lines of text.

Microfloat might give you a small variences, but its Standard deviation of varience will be so high that you can consider it to all be networking noise.

Not on the server? - So do you mean the web browser will be doing double the work?
Link to comment
https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426069
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.