php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47519 array key access reports notice
Submitted: 2009-02-27 10:37 UTC Modified: 2009-02-27 15:50 UTC
From: markus dot staab at redaxo dot de Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.9 OS: Vista Business
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: markus dot staab at redaxo dot de
New email:
PHP Version: OS:

 

 [2009-02-27 10:37 UTC] markus dot staab at redaxo dot de
Description:
------------
access a array key results in a undefined string offset notice. 

When swapping lines 
$params  = $params['params'];
$divider = $params['divider'];

to 
$divider = $params['divider'];
$params  = $params['params'];

no notice is reported..

PS: Appears in PHP4 and also PHP5.2.8 (5.2.9 not yet tested)

Reproduce code:
---------------
$params = array (
  'id' => 1,
  'name' => 'Home',
  'clang' => 0,
  'params' => '',
  'divider' => '&',
  'extension_point' => 'URL_REWRITE',
  'subject' => '',
);

$id      = $params['id'];
$name    = $params['name'];
$clang   = $params['clang'];
$params  = $params['params'];
$divider = $params['divider']; // line reports notice


Expected result:
----------------
no notices at all

Actual result:
--------------
Notice: Uninitialized string offset: 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-27 15:50 UTC] kalle@php.net
Its because your overridding the $params array by assigning a new value, and since the [] operator also can be used for string offsets then that notice is produced, not a bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 12:01:27 2024 UTC