Somehow I've learned a great deal about php yet have not ever attempted functions do to a bad experience with them in C++ but its time for me to learn.
Anyways my objective is to save myself a lot of coding over a 50 page period and use a functions.php file for most basics. My question is it possible to have 2 files, your normal page and then your functions. I wanna do something like this for error checking at the beginning.
// Page 1
$maparea = 1;
$continent = 1;
include("functions.php");
error();
Naturally above the page 1 I call upon mysql and set up a few things for the user, now on the functions page I basically want to check and see if a user is equal to whatever I just assigned $continent, So here is my functions file.
function error()
{
if ($user[continent] != $continent) {
print "You currently can not access this map due to being on a different continent.";
exit;
}
}
As you can see IF the user's continent isn't equal to continent it displays an error and then I want the page to completely stop. Here are the problems, $continent is not showing up in the function, I need to define the continent on each page as it will greatly change depending on pages. Also it is not outputting the print statement correctly and thus the exit statement is not working. This is my objective and I'm not sure if functions can do stuff like this but hopefully you guys can give me some more insight.