Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,155,544 members, 7,827,036 topics. Date: Tuesday, 14 May 2024 at 05:19 AM

Separating HTML And PHP Code - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Separating HTML And PHP Code (1312 Views)

Free New E-book On HTML And CSS / Please Help Me With Php Code To Submit Picture To Database / Php Code For Search Bar (2) (3) (4)

(1) (Reply)

Separating HTML And PHP Code by rock2(m): 1:50pm On Jan 13, 2007
This is for our web developers. How do you seperate your code(PHP) from the HTML design. I mean making them independent of each other. Thanks.
Re: Separating HTML And PHP Code by my2cents(m): 2:35pm On Jan 13, 2007
I separate my code (not limited to PHP) from HTML in one of 2 ways:

1) use of includes (e.g. require_once()):

<?php require_once('header.php'); ?>
<table>
<tr>
<td>
Hello Nairaland!!
</td>
</tr>
</table>
<?php require_once('footer.php'); ?>

2) beginning my code tabbed over once from the line and my HTML tabbed over 2ce from the line. In other words, take PHP for example:

<?php
$uri = $_SERVER['REQUEST_URI']; //to obtain what comes after www.nairaland.com in address bar above

if(strchr($uri, "topic=35738"wink { //does the uri contain the string, "topic=35738"?
?>
<table>
<tr>
<td>
Hello Nairaland!!
</td>
</tr>
</table>
<?php
} else {
?>
<table>
<tr>
<td>
Hello Nigeriaworld!!
</td>
</tr>
</table>
<?php
}//if
?>

Of course, for #2, I could hv printed out the strings without using tables. I just wanted to illustrate indentation tongue

I hope this helps
Re: Separating HTML And PHP Code by jacktoco: 5:44pm On Oct 01, 2018
Lovely information, I hate file like .tpl where html and php is all together.

(1) (Reply)

Configuring Bulletin Board Or A Forum / Website Designer Needed Urgently For A Freelance Job In Abuja / Free Domain Registration And Hosting

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.