| a | b | |
|---|
| 0 | + | --TEST-- |
|---|
| 0 | + | json_decode() function - a test to verify that json_decode() returns NULL on an invalid json string |
|---|
| 0 | + | --SKIPIF-- |
|---|
| 0 | + | <?php if (!function_exists('json')) echo "SKIP"; ?> |
|---|
| 0 | + | --FILE-- |
|---|
| 0 | + | <?php |
|---|
| 0 | + | /** |
|---|
| 0 | + | * All values were verified to be invalid JSON on jsonlint.com. |
|---|
| 0 | + | * |
|---|
| 0 | + | * Therefor, json_encode() should return NULL on those values as noted in the documentation. |
|---|
| 0 | + | * |
|---|
| 0 | + | * @link http://bugs.php.net/bug.php?id=45989 |
|---|
| 0 | + | */ |
|---|
| 0 | + | var_dump(json_decode("'invalid json'")); |
|---|
| 0 | + | var_dump(json_decode('invalid json')); |
|---|
| 0 | + | var_dump(json_decode(' {')); |
|---|
| 0 | + | var_dump(json_decode(' [')); |
|---|
| 0 | + | ?> |
|---|
| 0 | + | --EXPECT-- |
|---|
| 0 | + | NULL |
|---|
| 0 | + | NULL |
|---|
| 0 | + | NULL |
|---|
| 0 | + | NULL |
|---|
| ... | |
|---|