Need to check whether a param exists!
| From: | Brian Dunning | Date: | Mon, 03 Feb 2003 16:54:54 +0000 |
| Subject: | Need to check whether a param exists! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-134141@lists.php.net to get a copy of this message | ||
Hi,
All I'm trying to do is check for the presence of a query string, but everything I try gives me an Undefined Index error. I want to set a variable $pagename to whatever was passed as the ?page= value, and if it wasn't passed, set it to some default value.
http://www.mysite.com/index.php?page=hello
<?php
if (is_object($_REQUEST['page']))
$pagename = $_REQUEST['page'];
else
$pagename = "home";
?>
I also tried is_null, tried if($_REQUEST) by itself, also tried all of these with $_GET, $_POST, $_GLOBAL, but they all give me Undefined Index error on that If line.
- Brian