php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70097 weird string auto casting to array
Submitted: 2015-07-18 19:33 UTC Modified: 2016-02-15 13:09 UTC
Votes:5
Avg. Score:2.6 ± 1.5
Reproduced:2 of 3 (66.7%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: icestarsnowy at gmail dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 7.0Git-2015-07-18 (snap) OS: any
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: icestarsnowy at gmail dot com
New email:
PHP Version: OS:

 

 [2015-07-18 19:33 UTC] icestarsnowy at gmail dot com
Description:
------------
I am using the charter position for doing something with string and for some reason when a string is empty it will automatic cast to array which i am not sure is it supposed to happen.

Test script:
---------------
$str = "";
$str[0] = "b";
var_dump($str);

$str = "a";
$str[0] = "b";
var_dump($str);

Expected result:
----------------
string(1) "b"
string(1) "b"

Actual result:
--------------
array(1) {
  [0]=>
  string(1) "b"
}
string(1) "b"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-18 19:50 UTC] cmb@php.net
See also <http://3v4l.org/S7Hv9>.
 [2016-02-15 13:09 UTC] francois@php.net
-Status: Open +Status: Duplicate -Operating System: windows 8 +Operating System: any
 [2016-02-15 13:09 UTC] francois@php.net
Duplicate of bug #53432
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC