The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
if (!ereg(".inc$", $File)) {
$File .= ".inc";
}
..::STUFF::..
?>
*cough*
:)
Alternativly, try this:
using the same $File in the Web Address, but including the whole file you want to include:
http://www.yoursite.com/index.php?File=Page1.inc
http://www.yoursite.com/index.php?File=Page2.inc
http://www.yoursite.com/index.php?File=Page3.inc
etc...
and try use this:
if (file_exists("$File")) {
include("$File");
} else {
include("index.inc");
}
?>
It checks the file is there first and includes it, but if it's not there (for whatever reason) the index is shown :o)
If thats any better, and easier to understand, not to mention less to write when adding new pages, then use that :o)
Lets just say that your links were set up with the $File as the variable.
http://www.yoursite.com/index.php?File=Page1
http://www.yoursite.com/index.php?File=Page2
http://www.yoursite.com/index.php?File=Page3
etc...
and your files which your including are in the same location as the index.php file(ie the htdocs folder)
have this type of code in the index page:
switch($File) {
case "Page1" :
include("Page1.inc");
break;
case "Page2" :
include("Page2.inc");
break;
case "Page3" :
include("Page3.inc");
break;
default:
include("index.inc");
}
?>
The $File is used to checked and if a match is found, the specified include is used, if no match is found, the default is used, which is likely to be your index file anyway.
For this example, i've assumed that your extra files that you want to include are .inc files, as in include files, but you can have any file type you like: .html, .htm, .php etc...
Hope that was clear enough for you to understand, if not, let me know and I'll try again :o)
Cheers
You could use what Turbo said, or a little mor complex, but with the IF or SWITCH statments thing.
I'll write an example of a switch later if you want one.
Um...
I think so. Just set the file to reference as $file, call index.php as index.php?file=foo, and put in index.php
Is that it?