php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28917 Extremly unuseful behavior of $string[index]-feature
Submitted: 2004-06-25 12:41 UTC Modified: 2004-06-25 18:15 UTC
From: aulbach at ssilk dot de Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.7 OS: linux
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: aulbach at ssilk dot de
New email:
PHP Version: OS:

 

 [2004-06-25 12:41 UTC] aulbach at ssilk dot de
Description:
------------
The following code produces this result:

a2345

This behaviour is not very useful, because this kind of error is extremly difficult to find.



Reproduce code:
---------------
<?php
$in=array(
    'params' => 'action=bla',
    'action' => '',
    );
$params="12345";
// by error $params is a string
// instead of array or empty

$params['action']=@$in['params'];
// and the following 2000 lines
// of code is able to handle $params either
// as array OR string (e. g.
// cause of backward compatibility to
// further versions of $in)

print_r($params);
?>

Expected result:
----------------
One (or more) of these

* an array (
[0] => 12345
[action] => action=bla
)

* if this result above, a warning message
'String is automagically converted to array, line 8'

* an error message
'A string cannot indiced via string-type, use integer only, line 8'

* a warning message
'Use of [] while indexing a string is depricated, use {}, line 8'

* an error message
'Use of [] while indexing a string is not longer allowed, use {} instead, line 8'


Actual result:
--------------
a2345


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-25 18:15 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Not a bug. 
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 12:01:36 2025 UTC