Created
November 17, 2015 05:14
-
-
Save Teino1978-Corp/8292df39f60ae631c81f to your computer and use it in GitHub Desktop.
playing with php to check ifJson
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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