Article promotion master Community Supporter?
World Wide Whale
Posts: 155
811 credits Members referred : 0
« on: Feb 26, 2006, 06:13:24 AM »
How do you normally render HTML output in your php pages? Do you use small php blocks to write the actual php code or do you print the html code also in the php block itself? Which is advisable? Will having the html also in the php code print statements slow down the page?
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
How do you normally render HTML output in your php pages? Do you use small php blocks to write the actual php code or do you print the html code also in the php block itself? Which is advisable? Will having the html also in the php code print statements slow down the page?
its actually quite simple. im not a php expert but im somewhat familiar, you can use most html code inside php echo and print statements as long as you dont use quotes like ". and no i dont believe it slows down the parsing of the code, your server (if it supports php latest versions) will parse php files automatically once they are access via a web browser..
sorry, forgot to include an example:
Code:
<?php echo "<html><body><head><title>Your site</title></head><body><p align='center'>Hello!</p></body</html>"; //On this line you would have some other php code such as arrays, if else statements, etc. that is the actual "parsing" i believe you are referring to? ?>
« Last Edit: Feb 26, 2006, 08:18:42 AM by Meth0d »
Article promotion master Community Supporter?
World Wide Whale
Posts: 155
811 credits Members referred : 0
« Reply #4 on: Feb 26, 2006, 11:23:48 AM »
I understand both methods but which do you prefer and why? That was what I wanted to know..
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 8266
42583 credits Members referred : 3
« Reply #5 on: Feb 26, 2006, 11:40:16 AM »
Hmm, very interesting question.
I tried to test those before some time with compiled php (eAccelerator)
The result was that php pages with echo/print_r statements was faster than simple html files! But of course this applies for eaccelerator with caching on.
I am not sure what of the above would be best for a php implementation without an encoder.
Global Moderator
Internet Junkie
Gender:
Posts: 1523
6847 credits Members referred : 8
Gimme all your cookies!!!
« Reply #6 on: Feb 26, 2006, 03:33:01 PM »
I don't think that it makes any difference, and you could probably only test it on a huge page to see any real difference in speed. I normally use a print or echo for smaller pieces of html and then a would break out of php for long sections of html. It is up to you which to use...
I don't think that it makes any difference, and you could probably only test it on a huge page to see any real difference in speed. I normally use a print or echo for smaller pieces of html and then a would break out of php for long sections of html. It is up to you which to use...
ya once the html starts to get complicated you just break out of PHP and it runs the code as normal as long as u reopen the PHP in the right spot
I don't think that it makes any difference, and you could probably only test it on a huge page to see any real difference in speed. I normally use a print or echo for smaller pieces of html and then a would break out of php for long sections of html. It is up to you which to use...
ya once the html starts to get complicated you just break out of PHP and it runs the code as normal as long as u reopen the PHP in the right spot
right keep the code readable, if you have less code and you don't have to update this code place it inside the html. But if you have a complex application write your code in extra files, functions and classes. Doing it this way it's easy to maintain the application and you can reuse the code in diff. files