Skip to content

Instantly share code, notes, and snippets.

@topherPedersen
Created March 1, 2019 06:18
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 topherPedersen/0032d094733b2cce5d3161314d8e00ae to your computer and use it in GitHub Desktop.
Save topherPedersen/0032d094733b2cce5d3161314d8e00ae to your computer and use it in GitHub Desktop.
Receive JSON POST Data with PHP
<?php
$data = json_decode(file_get_contents('php://input'));
$myVariable = $data->{'foo'};
$myOtherVariable = $data->{'bar'};
?>
{
"foo": "<?= $myVariable ?>",
"bar": "<?= $myOtherVariable ?>"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment