#49264 [Bgs]: Can use any scalar as an array
| From: | a dot dotreppe at aspyct dot org | Date: | Tue, 18 Aug 2009 17:03:16 +0000 |
| Subject: | #49264 [Bgs]: Can use any scalar as an array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-141207@lists.php.net to get a copy of this message | ||
ID: 49264
User updated by: a dot dotreppe at aspyct dot org
Reported By: a dot dotreppe at aspyct dot org
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Windows Vista 32bit
PHP Version: 5.3.0
New Comment:
I did search, but honestly, didn't find this 2 year old ticket...
Thanks for your kind answer, glad to help.
By the way, even if it's documented, it should be considered as a
bug... No serious language would allow this.
Previous Comments:
------------------------------------------------------------------------
[2009-08-18 07:23:21] jani@php.net
Thank you for not searching before submitting another report about same
issue. This is also documented already. See also bug #41195
------------------------------------------------------------------------
[2009-08-14 22:32:03] a dot dotreppe at aspyct dot org
Description:
------------
Hi
I just noticed that any scalar type could be used as an array.
This could be source of a long list of undetectable bugs.
Should this be considered as a bug ?
Except for strings, that should be indexable. But then, only with
numeric indexes, not strings (that are anyway evaluated to 0).
Reproduce code:
---------------
$value = false;
var_dump($value['hello']);
$value = 4;
var_dump($value['hello']);
$value = 74.6;
var_dump($value['hello']);
$value = 'hello';
var_dump($value['hello']);
Expected result:
----------------
Some Fatal error, something brutal that will halt the script.
Actual result:
--------------
NULL NULL NULL string(1) "h"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49264&edit=1