php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45085 {} is better than [] for string access
Submitted: 2008-05-24 01:00 UTC Modified: 2012-04-14 02:58 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: noah at dizzler dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 6CVS-2008-05-24 (CVS) OS:
Private report: No CVE-ID: None
 [2008-05-24 01:00 UTC] noah at dizzler dot com
Description:
------------
I am very upset that {} string access is being depreciated in PHP 6.

$foo = 'bar';
$foo{2} = 't';

In my opinion...

$foo{2} is MUCH easier to read and understand while developing, because you know exactly what it means, 

$foo[2] is ambiguous to read, and problematic during development because $foo could be an array or a string, and in either case the code will execute without errors or notices if $foo is not the vartype you intended it to be.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-13 20:30 UTC] nikic@php.net
Closing this as PHP 6 doesn't exist anymore and {} is not deprecated in 5.4.
 [2012-04-13 20:30 UTC] nikic@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: nikic
 [2012-04-14 02:58 UTC] aharvey@php.net
-Status: Closed +Status: Not a bug -Assigned To: nikic +Assigned To:
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 01 20:01:29 2024 UTC