This is called the HTTP GET protocol.
It is used to transfer data between pages, but being a pretty old protocol, it has limitations, such as length restrictions (due to URL length restrictions) aswell as character restrictions. (# and other special characers are not available using GET)
You can add GET variable on any URL by adding a ? sing at the end of the URL. Then you can add variables formatted like this "varName=varValue". To add more than one you can seperate them usint a & sign.
Example: index.php?var1=value1&text=Thisistext1
Now you could access those variables in PHP using the $_GET array
Example using the URL in the previous example.
-
print $_GET['var1']; //Outputs: value1
-
print $_GET['text']; //Outputs: Thisistext1
-
You can also access this data usint the $_REQUEST array. This array is different however. It does not only contain GET data. It also containts POST and COOKIE data. Depending on your PHP settings, identical variables in the other protocols might override your GET values.
Here are some examples of how GET values can be set.
-
// This link will refresh the page and change the
-
// GET variable text
-
echo "<a href='?text=fromalink'>Linkage</a>";
-
-
// This form will post its text field as the
-
// GET variable text
-
?>
-
<form action="?" method="GET">
-
Text: <input type="text" name="text" />
-
<br /> <input type="submit" text="Submit" />
-
</form>
-
<?php
-
-