Bug #79859 [Opn->Nab]: Array with null is true

From: Date: Tue, 14 Jul 2020 15:01:49 +0000
Subject: Bug #79859 [Opn->Nab]: Array with null is true
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228040@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79859&edit=1 ID: 79859 Updated by: nikic@php.net Reported by: giolaza at gmail dot com Summary: Array with null is true -Status: Open +Status: Not a bug Type: Bug Package: *General Issues Operating System: WIN 10 PHP Version: 7.2.32 Block user comment: N Private report: N New Comment: Any non-empty array is true under a bool cast. Previous Comments: ------------------------------------------------------------------------ [2020-07-14 15:00:51] giolaza at gmail dot com Description: ------------ 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79859&edit=1

« previous php.bugs (#228040) next »