|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65484 Accessing null variable as array over key
Submitted: 2013-08-20 08:02 UTC Modified: 2015-06-08 20:51 UTC
Avg. Score:3.9 ± 0.9
Reproduced:3 of 4 (75.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: jan dot kahoun at heureka dot cz Assigned: cmb (profile)
Status: Duplicate Package: Scripting Engine problem
PHP Version: 5.5.2 OS:
Private report: No CVE-ID: None
 [2013-08-20 08:02 UTC] jan dot kahoun at heureka dot cz
If you define variable as NULL and then you want to acces it over keys as array 
like $array['kolo'] then PHP should trigger a strict error and not return the NULL.

Test script:

$array = null;

Expected result:
PHP strict error

Actual result:

Expected result:
Expected is PHP strict error.

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-20 08:33 UTC]
-Package: *General Issues +Package: Scripting Engine problem -PHP Version: Irrelevant +PHP Version: 5.5.2
 [2013-08-20 08:33 UTC]
See also
bug #37676 using Array access operator [] on boolean variable does not show Notice
bug #40692 Trying to use boolean as array doesn't give an error

and a part of
bug #62769 Inconsistent notice reporting using []
 [2014-02-16 00:32 UTC] salsi at icosaedro dot it
$arr = NULL;

==> NULL !!! no warnings at all!

Tested with:
PHP 5.3.10
PHP 5.5.9
 [2015-06-08 20:51 UTC]
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2015-06-08 20:51 UTC]
Duplicate of request #37676.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Dec 10 18:01:27 2023 UTC