php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #38645 Does the documentation recommend brackets or curly braces for character access?
Submitted: 2006-08-29 21:48 UTC Modified: 2006-08-31 02:01 UTC
From: z_rules55 at hotmail dot com Assigned: philip (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2006-08-29 21:48 UTC] z_rules55 at hotmail dot com
Description:
------------
I see the documentation as inconsistent in its recommendation of how to access a string offset. PHP used to use brackets for accessing a character at an offset in a string, then braces, now back to brackets. http://us2.php.net/manual/en/language.types.type-juggling.php says:
"PHP 4 introduced the new curly bracket syntax to access characters in string, use this syntax instead of the one [using brackets] presented above"

But then it links you to the part on string access by character (http://us2.php.net/manual/en/language.types.string.php#language.types.string.substr), which states:
"[Characters within strings] may also be accessed using braces like $str{42} for the same purpose. However, using square array-brackets is preferred."

Why does that part of the documentation still say to "use this syntax [with braces] instead of the one [using brackets]"?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-31 02:01 UTC] philip@php.net
Using brackets is recommended. The type juggling section was overlooked because most of that information does not even belong there so it's now been removed. These changes will show up when the manual is next built, thank you for the bug report! :)

Diff is as follows:
http://cvs.php.net/viewvc.cgi/phpdoc/en/language/types.xml?r1=1.166&r2=1.167


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Nov 20 23:00:01 2025 UTC