Req #65484 [Com]: Accessing null variable as array over key

From: Date: Sun, 16 Feb 2014 00:32:09 +0000
Subject: Req #65484 [Com]: Accessing null variable as array over key
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184311@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65484&edit=1

 ID:                 65484
 Comment by:         salsi at icosaedro dot it
 Reported by:        jan dot kahoun at heureka dot cz
 Summary:            Accessing null variable as array over key
 Status:             Open
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 PHP Version:        5.5.2
 Block user comment: N
 Private report:     N

 New Comment:

error_reporting(-1);
$arr = NULL;
var_dump($arr[0]);

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

Tested with:
PHP 5.3.10
PHP 5.5.9


Previous Comments:
------------------------------------------------------------------------
[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)

« previous php.bugs (#184311) next »