|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80553 `json_decode()`-documentation has false information
Submitted: 2020-12-26 19:53 UTC Modified: 2020-12-26 21:32 UTC
From: lars at lquenti dot de Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 7.3.25 OS: Arch
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: lars at lquenti dot de
New email:
PHP Version: OS:


 [2020-12-26 19:53 UTC] lars at lquenti dot de
The documentation mentions the following:

Values true, false and null are returned as true, false and null respectively.

As shown in the test script, `json_decode(false)` returns `null` instead of false.
`json_decode(true)` works as expected.

Test script:
<?php echo is_null(json_decode(false)) ?>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-26 19:58 UTC]
-Status: Open +Status: Not a bug
 [2020-12-26 19:58 UTC]
I don't see a problem with the documentation. It says: "null is returned if the json cannot be decoded". You are passing invalid value (false) so the function fails. When it fails it returns NULL as described. 

I believe you misunderstood that other note. Consider the correct example:

<?php var_dump(json_decode("false"));

This will return native PHP value false. The output is:


Please note that the first parameter of json_decode is string. It does not accept any other value, which means booleans are not valid and the function will fail.
 [2020-12-26 21:32 UTC] lars at lquenti dot de
I'm so sorry, you are right... Again, I'm sorry for the inconvenience.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 08:03:37 2021 UTC