note 47221 added to reserved.variables

From: Date: Sun, 07 Nov 2004 03:15:23 +0000
Subject: note 47221 added to reserved.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-80207@lists.php.net to get a copy of this message
I need a way to load a page depending on the $_GET value entered (or $HTTP_GET_VARS depending on your version or coding standard.) So, I could use longer urls like so: a=feeds&feed=rss or I could do something like: feed=rss But how? I can't load it without knowing the query string value being feed (?feed=). So I just came up with: <?php $get = explode("?", $_SERVER['QUERY_STRING'],1); $get = $get[0]; $query_string = explode("=", $get, 2); $query_string = $query_string[0]; ?> and $query_string would be id (if you entered id=something) Therefor I could do: <?php $pages = array( 'profile' => "profile", 'comment' => "comment", 'trackback' => "trackback", 'archives' => "archives", 'category' => "category", 'options' => "options", 'feeds' => "feeds", 'index' => "main", 'search' => "search", 'calendar' => "calendar", ); if (empty($pages[$query_string]) ) { $_GET[$query_string] = 'index'; $pages[$query_string] = "main"; } /* After the check Require the source file and display */ require_once (home."includes/pages/".$pages[$query_string].".php"); $load = new $pages[$_GET[$query_string]]; ?> (I have home set as ./: <?php define("home", "./"); ?> ---- Manual Page -- http://www.php.net/manual/en/reserved.variables.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47221 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47221&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47221&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47221&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47221&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47221&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47221&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47221&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80207) next »