php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64444 Use of quantitative scalar as array.
Submitted: 2013-03-18 06:59 UTC Modified: 2013-03-21 11:23 UTC
From: koushky at gmail dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.3.23 OS: ubuntu 12.10
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: koushky at gmail dot com
New email:
PHP Version: OS:

 

 [2013-03-18 06:59 UTC] koushky at gmail dot com
Description:
------------
If the variable is a quantitative scalar (excluding the strings) and access as 
array type, php does not returned notice error.

Test script:
---------------
$array = 1;
var_dump($array[0]); // doesn't return notice error

Expected result:
----------------
NULL

Actual result:
--------------
PHP Notice:  Undefined offset: 0 in Command line code on line 1
NULL

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-21 11:23 UTC] kalle@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The 'array access' syntax only works for arrays and strings, strings also got curly braces: $str{0} to access a certain byte index in that string.

So yes, this is intended, as the behavior for usage on other types are undefined.
 [2013-03-21 11:23 UTC] kalle@php.net
-Status: Open +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Sep 07 23:01:27 2024 UTC