php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #26414 No documentation on modifying a string by indexing and assignment
Submitted: 2003-11-25 16:17 UTC Modified: 2003-11-25 17:46 UTC
From: stephen dot fromm at verizon dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: irrelevant
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: stephen dot fromm at verizon dot net
New email:
PHP Version: OS:

 

 [2003-11-25 16:17 UTC] stephen dot fromm at verizon dot net
Description:
------------
The PHP documentation nowhere indicates whether it's legal to *modify* a string by accessing an individual character in the string with the index operator (curly braces) and an assignment statement, as in:
$str = '0123456789';
$str{4} = 'd';
// Now $str should be '0123d56789'

While it does work on my machine, I feel the behavior
should be documented, as
* for all I know, there may be strange side effects (given php's complex copy semantics);
* using undocumented language features can result in code that doesn't age or port well;
* this is a fundamental aspect of any computer language.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-25 17:01 UTC] ali@php.net
Here:
http://www.php.net/manual/en/language.types.type-juggling.php

you find the behaviour documented. I'll will add a small  example to the "Strings" section, so that it will be clarified and seen faster.


 [2003-11-25 17:46 UTC] goba@php.net
Closed, not bogus, as there was a confirmed bug and it was fixed. The manual only documented access by index and not modification...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 23:01:33 2025 UTC