note 29248 deleted from language.variables.predefined by cece
| From: | cece@php.net | Date: | Tue, 01 Feb 2005 14:35:48 +0000 |
| Subject: | note 29248 deleted from language.variables.predefined by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-84327@lists.php.net to get a copy of this message | ||
Note Submitter: LouisGreen at pljg dot freeserve dot co dot uk
Reason: useless
----
Not long ago I had a problem understanding how the $_GET works, so I create this little PHP program
to help me understand better. Let's say you have a file index.php and you are accessing it with
few variables in the addrress (index.php?type=show&sort=desc&foo=bar). Now, the question you
wondering is how to access that variables? You could use $type, $sort and $foo in this example...
but what if register_globals are off? Then, you need to access them with other function...
<?php
echo "Test for URL varibles using \$HTTP_GET_VARS[\"op\"]<P>";
if (isset($HTTP_GET_VARS["op"])) {
echo "var op = ".$HTTP_GET_VARS["op"]."<P>";
}
echo "<a href=\"url_varibles.php?op=test_sucess\">URL Variable
Link</a>";
//----------------------------------------------------------
echo "<P><HR>Test for URL varibles using \$_GET['type']<P>";
echo "<a href=\"url_varibles.php?type=show&sort=desc&foo=bar\">URL
Variable Link</a>";
if (isset($_GET['type'])) {
echo "<P>Here are our variables: <br >\n";
echo "1. ". $_GET['type'] ."<br />\n";
echo "2. ". $_GET['sort'] ."<br />\n";
echo "3. ". $_GET['foo'] ."<br />\n";
}
?>