Req #65484 [Opn->Dup]: Accessing null variable as array over key
Edit report at https://bugs.php.net/bug.php?id=65484&edit=1
ID: 65484
Updated by: cmb@php.net
Reported by: jan dot kahoun at heureka dot cz
Summary: Accessing null variable as array over key
-Status: Open
+Status: Duplicate
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: 5.5.2
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Duplicate of request #37676.
Previous Comments:
------------------------------------------------------------------------
[2015-05-12 21:08:45] cmb@php.net
Related To: Bug #64194
------------------------------------------------------------------------
[2015-05-12 21:06:24] cmb@php.net
Related To: Bug #48560
------------------------------------------------------------------------
[2014-02-16 00:32:08] salsi at icosaedro dot it
error_reporting(-1);
$arr = NULL;
var_dump($arr[0]);
==> NULL !!! no warnings at all!
Tested with:
PHP 5.3.10
PHP 5.5.9
------------------------------------------------------------------------
[2013-08-20 08:33:54] requinix@php.net
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 []
------------------------------------------------------------------------
[2013-08-20 08:02:27] jan dot kahoun at heureka dot cz
Description:
------------
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:
---------------
<?php
$array = null;
var_dump($array['kolo']);
/*
Expected result:
PHP strict error
Actual result:
NULL
*/
Expected result:
----------------
Expected is PHP strict error.
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65484&edit=1
Thread (4 messages)