Hello!
I’m using the following syntax to bring content into my websites’ layout template:
<?php //check in the root folder first
if(file_exists('./' . $pagename . '.php'))
{
include './' . $pagename . '.php';
}
//if it wasn't found in the root folder then check in the news folder
elseif(file_exisits('./news/' . $filename . '.php'))
{
include './news/' . $pagename . '.php';
}
// if it couldn't be found display message
else
{
echo $pagename . '.php could not be found in either the root folder or the news folder!';
} ?>
What it’s essentially saying is, if you can’t find the .php file in the _root folder, look for it in the /news/ folder.
It works perfectly if loading something from the _root folder but I get an error if I need to bring something from the /news/ folder.
Can anyone see any potential problems with my code?
Thank you very much and I hope to hear from you.
Take care,
Mark