Dysan Posted December 30, 2007 Share Posted December 30, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/ Share on other sites More sharing options...
hitman6003 Posted December 30, 2007 Share Posted December 30, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426012 Share on other sites More sharing options...
Dysan Posted December 30, 2007 Author Share Posted December 30, 2007 Can you do the code for me for both of them, just in case I get it wrong? Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426024 Share on other sites More sharing options...
hitman6003 Posted December 30, 2007 Share Posted December 30, 2007 Try it yourself. If it doesn't work, post your attempt and someone will help. Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426029 Share on other sites More sharing options...
Dysan Posted December 30, 2007 Author Share Posted December 30, 2007 OK Cheers Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426033 Share on other sites More sharing options...
Dysan Posted December 30, 2007 Author Share Posted December 30, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426035 Share on other sites More sharing options...
hitman6003 Posted December 30, 2007 Share Posted December 30, 2007 You'll have to close the php tag, and then reopen it... <?php $start = microtime_float(); ?> <table border="1"> <tr> ..... </table> <?php echo "Rendered in " . (microtime_float() - $start) . " seconds"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426039 Share on other sites More sharing options...
Dysan Posted December 30, 2007 Author Share Posted December 30, 2007 That's not very accurate, as at one time both pages/files had the same loading time, and another time one takes longer than the other. It's not a fair test. Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426049 Share on other sites More sharing options...
hitman6003 Posted December 30, 2007 Share Posted December 30, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426053 Share on other sites More sharing options...
Dysan Posted December 30, 2007 Author Share Posted December 30, 2007 I don't think theres much difference anyway in time, between the to methods, which method would you use? Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426055 Share on other sites More sharing options...
cooldude832 Posted December 30, 2007 Share Posted December 30, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426060 Share on other sites More sharing options...
Dysan Posted December 30, 2007 Author Share Posted December 30, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426069 Share on other sites More sharing options...
cooldude832 Posted December 30, 2007 Share Posted December 30, 2007 Sorry didn't finnish my thought 1) Your server makes the text show up (PHP processing) 2) The browser displays it When its just html you skip step 1 as PHP has no processing to complete. Quote Link to comment https://forums.phpfreaks.com/topic/83733-processing-power/#findComment-426070 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.