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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC