Re: Representing a variable

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

 



Ron Piggott wrote:

> I am wondering how to correctly represent the variable
> $params['en-US_translation']
> 
> $value = 'en-US';
> 
> What I currently have is
> 
> $params[{$value . '_translation'}]

That is supposed to be a syntax error (see <http://3v4l.org/QQ2uI>).
Either omit the curly braces:

  $params[$value . '_translation']

or use variable interpolation:

  $params["{$value}_translation"]

You can't, however, use the following:

  $params["$value_translation"]

That would look for a variable $value_translation.

See also
<http://php.net/manual/en/language.types.string.php#language.types.string.parsing>.

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