OiO.lk Blog PHP How to verify if $_GET exists?
PHP

How to verify if $_GET exists?


Consider the following PHP:

<?php
if (in_array('cookie_name', $_GET, false)) {
    echo "Found";
}
var_dump($_GET);
echo $_GET['cookie_name'] . "\n";
?>

If I put this on a webserver and use curl with cookie_name=xxx, I get the following output, which does not include the string Found.

array(1) {
  ["cookie_name"]=>
  string(3) "xxx"
}
xxx

I feel that I must be using in_array incorrectly but I do not see how.

Any hints?



You need to sign in to view this answers

Exit mobile version