Re: ${0} variable basics

From: Date: Mon, 25 Aug 2014 14:25:50 +0000
Subject: Re: ${0} variable basics
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-323791@lists.php.net to get a copy of this message
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

« previous php.general (#323791) next »