Ahmad Farid
Ahmad Farid

Reputation: 14774

How to read the query string in PHP and HTML?

a URL ending with something like portal.php?key2=hello how can I get the value of "key2"?

Upvotes: 8

Views: 22137

Answers (3)

johannes
johannes

Reputation: 15969

GET data is decoded into the $_GET super-global array. See http://php.net/manual/en/language.variables.external.php

Upvotes: 2

Gav
Gav

Reputation: 11460

$_GET['key2']

will get you the value from a query string.

$_POST['key2']

will get you the value from a form posted.

$_REQUEST['key2']

will get you either of the above if it exists.

Upvotes: 17

meder omuraliev
meder omuraliev

Reputation: 186562

var_dump( $_GET['key2'] );

Upvotes: 8

Related Questions