View Single Post
Old 11-11-2004, 12:48 PM   #1 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 230
falsepride is on a distinguished road
include vs. str_replace

a lot of people will include a header and footer on their pages and just have the content in the middle be different, or do content includes. i found a way thats in my opinion is twice as clean. make a file called layout.html, and where you want certian things to be put [Menu], [Content], [Poll] etc. then in your index.php file use the following script at the bottom:
$layout = implode("", file("layout.html"));
$layout = str_replace("[Menu]", $menu, $layout);
$layout = str_replace("[Content]", $content, $layout);
$layout = str_replace("[Poll]", $poll, $layout);
echo $layout;

that way if you decided to change your layout you dont have to worry about forgeting to close of a certian html tag, it'll be right in front of you. what do you guys think of this tip?
falsepride is offline   Reply With Quote