How to read a query string in PHP and HTML?

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

+7
html php query-string
source share
3 answers
 var_dump( $_GET['key2'] ); 
+8
source share
 $_GET['key2'] 

you will get the value from the query string.

 $_POST['key2'] 

will provide you the value from the published form.

 $_REQUEST['key2'] 

will provide you with any of the above, if one exists.

+17
source share

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

+2
source share

All Articles