Please Note: The code in this article uses the incorrect quotation marks (”), please subsitute with standard ones on your keyboard them when copying & pasting the code from this article.
Hey chaps, it’s time for something useful, lately we’ve been practically pounding you with game reviews, probably to the point you have actually forgotten what programming is – however, instead today, we are looking at the PHP get command, one of the most essential basics which will probably use in your scripts now you know of its existence.
The PHP Get, is a predefined superglobal built into PHP, meaning it is literally part of PHP. So lets take a look at PHP.net Description:
An associatve array of variables passed to the current script via the HTTP GET method.
Ok to simplify that even more, it means we can use get variable passed to it.
Lets assume you’ve got yourself a testing server ok, or just subsitute the localhost bit for your real server domain name & file location:
http://localhost/getcommand/get.php?name=alan
Ok so that’s the URL we’re going to use for this, this basically is a file we’re creating called get.php and after that is the variable name & value we are bringing in using the GET command we keep talking about. Ok next lets do the magic PHP, its simple.
<?php
$thatname = $_GET['name'];
echo “Your name is $thatname“;
?>
That it, I decided not to comment it, its easy enough, we start php off, then we use the get command. I’ve highlighted the variable names to make it easier, also remember if you copy and paste to put in the correct quotation marks. Thanks!
The get has endless possiblities and is a must have in your arsenal of coding knowledge, I will leave you with one more thing, which is 2 or more variables in a url:
http://localhost/getcommand/get.php?name=alan&age=20&giantbugcolour=red
There ya go, easy peasy.
Hope you found this useful. Thanks
Wuup Team







AS3 Basics: Sending Variables from AS3 to PHP | Wuup on 3 November, 2008
[...] our PHP Basics : Get Command – Using URL Queries & Variables tutorial to learn how to read the passed [...]
Bill Nunney on 5 November, 2008