8

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

3 Answers 3

17
$_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.

Sign up to request clarification or add additional context in comments.

Comments

8
var_dump( $_GET['key2'] );

2 Comments

var_dump displays the variable. You can always consult php manual (php.net) to know usage of a function.
var_dump is like a more informative version of echo used solely for debugging. So even if it was blank it would display something.
2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.