Sincerely Negin Nickparsa On Mon, Aug 25, 2014 at 12:51 PM, Domain nikha.org <mail@xxxxxxxxx> wrote: > > Christoph Becker am Montag, 25. August 2014 - 16:25: > > Negin Nickparsa wrote: > > > why ${0} is valid but ${0 is not valid? > > > it means that curly braces evaluate what's inside them > > > > No, at least not in the general case. This notation is called "simple > > syntax" in the PHP manual[1] and "Variable-Name Creation > > Operator/Expression" in the current draft of the PHP language > > specification[2]. > > > > > and that's why we > > > cannot have ${0? > > > > > > variables shouldn't start from 0 so it means that it started from > braces? > > > if yes why I cannot have ${0? and what is the variable here finally? > $0 is > > > what it interprets? > > > > Yes, indeed. However, the notation $0 would be a syntax error. > > > > > if yes so it is not a legal variable > > > > Well, actually it is a legal variable, but it might better be avoided to > > use such variables. They are confusing, and I can't think of any > > advantage in using such variables. Use $zero instead, or maybe an array. > > > > > I am totally mixed up. > > > > [1] > > < > http://php.net/manual/en/language.types.string.php#language.types.string.parsing.simple > > > > [2] > > < > https://github.com/php/php-langspec/blob/master/spec/10-expressions.md#user-content-variable-name-creation-operator > > > > > > -- > > Christoph M. Becker > > > > The manual is not realy clear in this point. My practical expierence says > this: > an expression like "${....}" is always evaluated as string. ${0} creates a > variable named "0", because "0" is not the integer, that would be illegal. > > And BTW: ${0000.578} gives you "0000_578", because dots in variable names > are not allowed and automatically converted to underscores. And it is NOT > evaluated to a float. > > Confusing, and indeed avoid it! > > > The fabulous type juggling of PHP operates on the values, not the names of > variables! > > Why the hell you really need a variable named "0"? :) Niklaus Actually I guess nobody need that and you're absolutely right. It was a practice question that I failed to answer correctly and I was frustrated too. Thank you so much for your guidance. Since variables are denoted by the lead $ character I can't think of a good reason why a variable can't start with a number after the $ since the parser already knows it's working with a variable. I would imagine that it's a convention carried forward from C or other languages. Robert, Thank you so much for nice explanation and examples I really appreciated. -- > Niklaus > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >