[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    [PHP] Re: ${0} variable basics
From:       Negin Nickparsa <nickparsa () gmail ! com>
Date:       2014-08-25 22:09:41
Message-ID: CAJGV41dbMcTpL=7oOZMHp=RXOa6hCEhqwX6MAd=2wdCpjO+z9Q () mail ! gmail ! com
[Download RAW message or body]


Sincerely
Negin Nickparsa


On Mon, Aug 25, 2014 at 7:25 AM, Christoph Becker <cmbecker69@gmx.de> wrote:

> 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.
> 
> 
​yes Christoph! all I was saying that I cannot understand it evaluates to
0​ but it is legal to write it that way but it is not legal before
interpretation.Thank you

> > 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
> 



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic