views:

37

answers:

1

I have one file index.php, I am trying to include splash.php when no variable is passed and display.php when any variable is passed.

This is what i have so far but i want to make it universal for all variables instead of just "query".

if (!isset($_REQUEST['query']))
{
include("splash.php");
}
else {
include("display.php");
} 
+2  A: 
if (count($_REQUEST) == 0) {
   include("splash.php"); 
} else { 
   include("display.php"); 
}  

though you're better checking $_POST or $_GET (as appropriate) rather than the looser $_REQUEST

Mark Baker
Note that depending on your php.ini cookies might be included in the `$_REQUEST` array too. So checking if `count()` is zero might fail when you have a session running (or set any other cookies). `$_POST` and `$_GET` clearly are better candidates.
svens
@svens - hence my additional comment about $_GET and $_POST
Mark Baker