PHP: How to get keyless URL parameters -
i parameter in key such http://link.com/?parameter
i read somewhere key null
, value parameter
.
i tried $_get[null]
didn't seem work.
here code:
if ($_get[null] == "parameter") { echo 'invoked parameter.'; } else { echo '..'; }
it prints out ..
means i'm not doing right. can please show me right way.
there no such things keyless url parameters in php. ?parameter
equivalent of $_get['parameter']
being set empty string.
try doing var_dump($_get)
url http://link.com/?parameter , see get.
it should this:
array (size=1) 'parameter' => string '' (length=0)
thus, can test in couple of ways depending on application needs:
if (isset($_get['parameter'])) { // } else { // else }
or
// recommended if you're 100% sure 'parameter' in url. // otherwise throw undefined index error. isset() more reliable test. if ($_get['parameter'] === '') { // } else { // else }
Comments
Post a Comment