28, May 2012

Render HTML through PHP - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Render HTML through PHP
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: Render HTML through PHP  (Read 2561 times)
Article promotion master
Community Supporter ?
World Wide Whale
***
Posts: 155
811 credits
Members referred : 0



« on: Feb 26, 2006, 05: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: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #1 on: Feb 26, 2006, 07:16:05 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?

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, 07:18:42 am by Meth0d »


Last blog : phpHaze 1.59.1 in Development
Article promotion master
Community Supporter ?
World Wide Whale
***
Posts: 155
811 credits
Members referred : 0



« Reply #2 on: Feb 26, 2006, 07:21:21 am »

Thanks meth0d.

But will editing the html code not be more difficult if we use this way?

Plus is there any script which will convert from html to php?
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1525
6359 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #3 on: Feb 26, 2006, 07:57:47 am »

You can also break out of php, put your html in and then start php again. Here is a sample:

Code:
<?php

// php code here

?>


<!-- html code here -->

<?php

// php code here again

?>



Last blog : Canonical URL Links / Tags
Article promotion master
Community Supporter ?
World Wide Whale
***
Posts: 155
811 credits
Members referred : 0



« Reply #4 on: Feb 26, 2006, 10: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: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #5 on: Feb 26, 2006, 10: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.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1525
6359 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #6 on: Feb 26, 2006, 02: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...


Last blog : Canonical URL Links / Tags
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #7 on: Feb 28, 2006, 09:28:34 am »

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 Cheesy


Last blog : phpHaze 1.59.1 in Development
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #8 on: Apr 03, 2006, 12:40:10 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...

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 Cheesy
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

Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=1585
Tags : php html browsers Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Render HTML through PHP
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 09:15:55 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 62.853
Total Topics: 11.033
Total Members: 21.459
Tutorials : 58
Resources : 929
Designs : 395
Latest Member: xoloindia

127 Guests, 3 Users online :

22 users online today:




Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.