• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

Template wrapping and implodes

Im not to sure how this works, i been seeings pieces of code on this and im still at a loss why this is used instead of includes. This is the type of pieces of codes i been looking at

$page1 = implode("", file("../templ/members/header.htt"));
$page2 = implode("", file("../templ/footer.htt"));
$pagads = implode("", file("../templ/ads.htt"));

Is it used like this? theres a template file, that file is put onto a page then you call these 3 files which already have the postioning in a differnt file. Is it somthing like this?
0
Lee-Bartlett
Asked:
Lee-Bartlett
  • 2
  • 2
1 Solution
 
hieloCommented:
>>$page1 = implode("", file("../templ/members/header.htt"));
that is just putting the contents of header.htt into the variable $page1. It does NOT automatically send the content to the browser. So, somewhere down the line it must explicitly be doing:
echo $page;

or perhaps is extracting some portion of the page only and echoing only the desired portion. The same applies to $page2 and $pageads
0
 
Lee-BartlettAuthor Commented:
Im still a little confused, are these varibles stored in like a functions folder or somthing. if you got a link to a page which explains the structuer, any more information would be greate
0
 
hieloCommented:
>>are these varibles stored in like a functions folder or somthing
I don't understand what you are asking

>>if you got a link to a page which explains the structuer
No link. The concept is simple actually. To clarify further, consider this:
$temp="hello world";

$temp is just a variable and you are "saving/storing" a string in it. The file() function will open the file you specify and will return an array with the file contents. Each array element correspondes to one line of content. implode() then "joins" those lines of content. So what you posted is equivalent to:

$content=array("hello","world");
$temp = implode("",$content);

at this point $temp contains "helloword", but is not automatially echoed. Thus far you have just stored a string value into $temp, but if you need to echo it, you need to do so explicitly:
echo $temp;
 
0
 
Lee-BartlettAuthor Commented:
Ty to my first question, i mean, if i wanted to use the file for like 9 pages i would be able to use the implode that file onto my page
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now