Ethan Webster
Ethan Webster

Reputation: 93

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 the username= part by using PHP?

Upvotes: 0

Views: 147

Answers (4)

Ayush Pateria
Ayush Pateria

Reputation: 630

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

Upvotes: 0

Arnaud Le Blanc
Arnaud Le Blanc

Reputation: 99911

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

Upvotes: 1

Julio César
Julio César

Reputation: 13266

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

Upvotes: 3

Fad
Fad

Reputation: 9858

Use the $_GET variable

$username = $_GET['username'];

Upvotes: 2

Related Questions