[TYPO3-core] Decisions and Changes to Coding Guidelines (CGL)

Karsten Dambekalns karsten at typo3.org
Fri Jan 31 10:59:15 CET 2014


Hi.

On 30.01.2014, at 20:45, JoH asenau <info at cybercraft.de> wrote:

>> so far I used $string[2], not with curly brackets. Do we want to use
>> curly brackets to make clear that $string is not an array (and use the
>> square-brackets for arrays)?
> 
> That was exactly the intention :-)
> There have been some rumours though, that {} would be removed in future versions of PHP, but it seems that this has been revoked already.

There was a time when rumors said [] was might be removed for strings, and {} was recommended. Then [] was going to stay and the use of {} is no longer recommended. The manual lists it as an alternative to [] in http://www.php.net/manual/en/language.types.string.php#language.types.string.substr and all examples use the [] syntax.

> IMHO it's a good idea to do it like that, since it won't confuse newbies who might not be familiar with array access to strings.

Confusion was exactly the reason to no longer recommend using {} - because {} is used for the “Complex (curly) syntax” explained in http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing

My 2 cents on this.

Regards,
Karsten


More information about the TYPO3-team-core mailing list