Created
July 23, 2014 20:49
-
-
Save stuffmc/194753a33748e21dc761 to your computer and use it in GitHub Desktop.
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
// curl -X POST -H "Content-Type: body=application/json" -d '{"logs":["xyz"]}' https://example.com/v1/log | |
$cont = file_get_contents('php://input'); | |
echo "cont: $cont\n"; // Outputs cont: {"logs":["xyz"]} | |
$log = json_decode($cont); | |
echo "log: $log\n"; // Never outputed. Even not "log:" |
But indeed you'd rather check first if $log is not NULL because that's the return value of json_decode() in case in invalid json string.
Thanks guys!!!
@loicm : That's not the issue here. Issue was getting $log
to echo
@PofMagicfingers this was because he wanted to access the object as a string as he didn't know how to deal with objects in php. But agree that it's error level didn't help him to debug as the error went silently…
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Never outputed surely because of error level.
I get :
Catchable fatal error: Object of class stdClass could not be converted to string
Try :
To get a debug string of an object use :