So I am trying to put together a small lightweight framework for some basic sites I’m building for my hosting customers and I’m attempting to call in to the index.php various includes.
I’ve got it figured out but feel that there’s got to be a better way to write the following if statement:
<?php
if('home'==$currentpage)
{
include('shared/footer.htm');
}
elseif('testing'==$currentpage)
{
include('shared/footer.htm');
}
elseif('training'==$currentpage)
{
include('shared/footer.htm');
}
elseif('contact'==$currentpage)
{
include('shared/footer.htm');
}
elseif('pricing'==$currentpage)
{
include('shared/footer.htm');
}
?>
I got the following to work sort of, it uses what ever the last item in the list is:
$arr = array('home', 'testing', 'training', 'contact');
foreach ($arr as &$value);
if ($value==$currentpage)
{
include('shared/footer.htm');
}
That one will display the footer.htm on the contact page but none of the others, if I switch it around then it show what ever item ends up last, I’ve also tried a foreach statement and it breaks the page so I gave it up and figured I’d ask for a lil help.
Thanks in advance.
1 Answer