October 24, 2024
Chicago 12, Melborne City, USA
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

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video