Re: ${0} variable basics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux