PHP URL查询

How exactly would I get the URL with PHP so I could do this:

profile.php?username=Blah

How would I get the 'Blah' from the username= part by using PHP?

In PHP there are global variables that hold parameters passed on the url or by posting a form. Some of this variables are $_GET, $_POST, $_REQUEST, $_FILES.

<?php
$username = $_GET['username']
echo $username;

You can read more on superglobal variables here: http://www.php.net/manual/en/language.variables.superglobals.php

Use the $_GET variable

$username = $_GET['username'];

The special $_GET[docs] variable is an array containing all parameters passed in the URL, like username in your example.

You can access them using the $_GET['parameter_name'] syntax:

$username = $_GET['username'];

See the manual page of this variable: http://docs.php.net/manual/en/reserved.variables.get.php

You can use $_GET['username'] to retrieve the username parameter value from the URL For more on this visit: http://www.w3schools.com/php/php_get.asp