Skip to content

Instantly share code, notes, and snippets.

@bharathraj-e
Created March 29, 2020 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bharathraj-e/ebb86a460f2ffcfd421c90ccff249420 to your computer and use it in GitHub Desktop.
Save bharathraj-e/ebb86a460f2ffcfd421c90ccff249420 to your computer and use it in GitHub Desktop.
Check request and finalize response
<?php
function err($err)
{
$res['state'] = false;
$res['err'] = $err;
echo json_encode($res);
die();
}
function check($query, $err)
{
if (!isset($_REQUEST[$query])) {
err($err);
}
}
function complete($data)
{
$res['state'] = true;
$res['data'] = $data;
echo json_encode($res);
die();
}
$data = array();
extract($_REQUEST);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment