Skip to content

Instantly share code, notes, and snippets.

@Teino1978-Corp
Created November 17, 2015 05:14
Show Gist options
  • Select an option

  • Save Teino1978-Corp/8292df39f60ae631c81f to your computer and use it in GitHub Desktop.

Select an option

Save Teino1978-Corp/8292df39f60ae631c81f to your computer and use it in GitHub Desktop.
playing with php to check ifJson
function isJSON($string){
return is_string($string) && is_object(json_decode($string)) ? true : false;
}
$app = '';
//if(isset($_POST['message'])) {
$message = '{"to": "me"}';
if(isJSON($message)) {
$msg = json_decode($message);
echo '---';
var_dump($msg);
} else {
var_dump($message);
}
// }.
//}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment