Joseph89Digimon
New Member
This is what I have so far:
<?
$page = $goto.".html";
if (file_exists($page)) {
include $page;
}
else if (file_exists($goto)) {
include $goto;
}
else{
require("404.html");
}
?>
Basicaly, I'm trying to get multiple else's. This is what I want my code to do:
Include (goto).html, if it doesn't exist include (goto).html, if neither exist, include (goto).php, if all 3 dont exist, include (goto), and lastly, if nothing works include 404.html.
Maybe having more than one else isn't the best method to go about solving this, but I have no idea what I'm doing.
The code above doesn't work, but if goto=index.html, it is supposed to do this:
include index.html.html
else include index.html.php
else include index.html
else include 404.html
In the above case, the code should make index.html appear if its the only valid file, if not, display 404.html as a last resort. In a nut shell, it is designed to keep searching until it finds a valid file extention or include no extention at all. In case I have both index.html and index.php in the same directory, I want it to search in a certain specified order, like for an index.html 1st, and if that doesn't exist it will search for index.php in a 2nd try.
Can anybody help me get this to work? Thanks
<?
$page = $goto.".html";
if (file_exists($page)) {
include $page;
}
else if (file_exists($goto)) {
include $goto;
}
else{
require("404.html");
}
?>
Basicaly, I'm trying to get multiple else's. This is what I want my code to do:
Include (goto).html, if it doesn't exist include (goto).html, if neither exist, include (goto).php, if all 3 dont exist, include (goto), and lastly, if nothing works include 404.html.
Maybe having more than one else isn't the best method to go about solving this, but I have no idea what I'm doing.
The code above doesn't work, but if goto=index.html, it is supposed to do this:
include index.html.html
else include index.html.php
else include index.html
else include 404.html
In the above case, the code should make index.html appear if its the only valid file, if not, display 404.html as a last resort. In a nut shell, it is designed to keep searching until it finds a valid file extention or include no extention at all. In case I have both index.html and index.php in the same directory, I want it to search in a certain specified order, like for an index.html 1st, and if that doesn't exist it will search for index.php in a 2nd try.
Can anybody help me get this to work? Thanks