PHP Include

Just a quick question guys…

I’m using these two lines as part of an Include function:

$_GET[‘page’];

Is it possible to ‘GET’ a blank variable, e.g. so I can just link to “?home.php”?

Hope that was clear, many thanks :smiley:

I would not include the “.php” or use the filename in your URL. You can do something like this:

[php]
// example: index.php?mypage

$page = (isset($_SERVER[‘QUERY_STRING’]) ? $_SERVER[‘QUERY_STRING’] : ‘’);
switch($page) {
default:
// if query_string is empty or not matching switch
include(‘include_home.inc.php’);
break;
case ‘mypage’:
// include mypage.php - notice how filename is different than query_string
include(‘include_mypage.inc.php’);
break;
}
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service