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
 [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-2021 The PHP Group
All rights reserved.
Last updated: Wed Oct 27 04:03:38 2021 UTC