Voting

: zero plus one?
(Example: nine)

The Note You're Voting On

theking at king dot ma
2 years ago
I use array_intersect for a quick check of $_GET parameters;

<?php declare(strict_types=1)

$_params = ['cust_id','prod_id'];
$_params_check = array_intersect(array_keys($_GET),$_params);
if(
count($_params_check) !== count($_params)) {
header("HTTP/1.1 400 Bad Request");
die();
}
?>

the file will die with a 400 error if cust_id or prod_id or both are missing from $_GET. But i could be used on $_POST and $_REQUEST as well obviously.

<< Back to user notes page

To Top