Created
January 30, 2016 17:33
-
-
Save dana-ross/1cfcdb3d35f1b18f4422 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
$good = json_decode('{ "label": "This is valid JSON", "value": 5 }' ); | |
$bad = json_decode('{ "label": This is invalid JSON, "value": 5 }' ); | |
if( is_null( $good ) ) { | |
echo "Couldn't parse good JSON\n"; | |
} | |
else { | |
echo $good->value . "\n"; | |
} | |
if( is_null( $bad ) ) { | |
echo "Couldn't parse bad JSON\n"; | |
} | |
else { | |
echo $bad->value . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment