- json_decode: documentation ( source)
- json_last_error: documentation ( source)
- json_encode: documentation ( source)
<?php
$foo = json_decode('[bar');
// many lines of code.
$bar = json_encode('Hello world!', JSON_THROW_ON_ERROR);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception("encoding went wrong!");
}
echo "All is fine";