11, October 2008

Render HTML through PHP - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ 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

Author Topic: Render HTML through PHP  (Read 1319 times)
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: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #1 on: Feb 26, 2006, 08: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, 08:18:42 AM by Meth0d »

Visit through proxy Visit through proxy Visit through proxy

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, 08: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: 1523
6847 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #3 on: Feb 26, 2006, 08: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 : Site of the Month - August 2007
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: Male
Posts: 8116
41653 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.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Internet Junkie
*****
Gender: Male
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...


Last blog : Site of the Month - August 2007
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



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

Visit through proxy Visit through proxy Visit through proxy

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


It's time to use PHP5!


« Reply #8 on: Apr 03, 2006, 01: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


Last blog : Upload images for usage in TinyMCE
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....

Topic sponsors:
Get a permanent link here for $1.99!


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?
Oct 11, 2008, 05:26:45 PM





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: 36.904
Total Topics: 7.557
Total Members: 4.149
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: mirela

29 Guests, 4 Users online :

13 users online today:



Readers

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