|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-02-17 04:34 UTC] yohgaki@php.net
Description:
------------
Both ${var} and {$var} are supposed to work, but ${$var} raises syntax error.
Test script:
---------------
php > $str = 'abc';
php > echo "${str{1}}";
PHP Parse error: syntax error, unexpected '{' in php shell code on line 1
php > echo "{$str{1}}";
b
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 07:00:01 2025 UTC |
This "bug" is best solved by deprecating the ${} interpolation syntax for non-expressions.@nikic Deprecating ${} is possible resolution. One concern is ${} is common in shell scripting languages. https://www.gnu.org/software/bash/manual/bashref.htmlNot sure I understand - where's the bug in here and what would you expect to happen? str{1} is not a valid token for variable name, and is not a valid string offset operation since str is not variable - $str is.