php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49264 Can use any scalar as an array
Submitted: 2009-08-14 22:32 UTC Modified: 2009-08-18 17:27 UTC
From: a dot dotreppe at aspyct dot org Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.0 OS: Windows Vista 32bit
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: a dot dotreppe at aspyct dot org
New email:
PHP Version: OS:

 

 [2009-08-14 22:32 UTC] 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" 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-18 07:23 UTC] jani@php.net
Thank you for not searching before submitting another report about same issue. This is also documented already. See also bug #41195
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 16:01:33 2025 UTC