|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
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: Wed Jul 28 04:01:25 2021 UTC