Detecting a NULL key/value pair in QUERY_STRING

From: Date: Sat, 28 Dec 2002 16:50:53 +0000
Subject: Detecting a NULL key/value pair in QUERY_STRING
Groups: php.dev 
Request: Send a blank email to php-dev+get-92915@lists.php.net to get a copy of this message
Folks, PHP newbie here...I'm writing a simple page that dynamically changes an included file based on the query string: <?php //error_reporting(0); $content = $_GET['content']; // line 3 if ($content == NULL) { // if no querystring or querystring doesn't contain 'content=foo' $content = "content/home.php"; } else { $content = "content/" . $content . ".php"; } ?> <body> <?php include($content); ?> </body> When the URL is "index.php?content=foo" all is fine. When I try "index.php", I get the following error message: "Notice: Undefined index: content in C:\\Apache2\htdocs\index.php on line 3" (doesn't like index 'content' in $_GET['content']) If I uncomment 'error_report(0)', the notice is ignored (but I don't really want to do that) and page renders fine with 'index.php'. Is this the only way? Thanks...rich

« previous php.dev (#92915) next »