|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79859 Array with null is true
Submitted: 2020-07-14 15:00 UTC Modified: 2020-07-14 15:01 UTC
From: giolaza at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.2.32 OS: WIN 10
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: giolaza at gmail dot com
New email:
PHP Version: OS:


 [2020-07-14 15:00 UTC] giolaza at gmail dot com
Array with first element null is true

Test script:
$arr = [ 0 => null];
if ($arr) {
    echo 'is true';
} else {
    echo 'is false';

//TEST 2 
$arr = explode(',', null);
if ($arr) {
    echo 'is true';
} else {
    echo 'is false';

Expected result:
is false

Actual result:
is true


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-14 15:01 UTC]
-Status: Open +Status: Not a bug
 [2020-07-14 15:01 UTC]
Any non-empty array is true under a bool cast.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Aug 15 22:05:43 2022 UTC