If a query maybe be optionally run as a get()
or a post()
, so that $id = $_POST['id']
maybe get a null value, are any of these a good practice way to test for the possibly posted variable's existence.
if (!empty($_POST['id'])){ $id = $_POST['id'];}else{$id = FALSE;}
if (isset($_POST['id'])){ $id = $_POST['id'];}else{$id = FALSE;}
$id = isset($_POST['id']) ? $_POST['id'] : FALSE;
or is there some other preferred method? They all do a $_REQUEST()
twice which inclines me to think there could be a better way.
Thanks!