开发者

PHP URL Inquiry

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 t开发者_如何转开发he 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜