note 14664 modified in language.variables.variable by danbrown
| From: | danbrown@php.net | Date: | Wed, 24 Jun 2009 17:02:22 +0000 |
| Subject: | note 14664 modified in language.variables.variable by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-157421@lists.php.net to get a copy of this message | ||
Note that normal variable variables will not be parsed in double-quoted strings. You'll have to
use the braces to make it work, to resolve the ambiguity. For example:
<?php
$varname = "foo";
$foo = "bar";
print $$varname; // Prints "bar"
print "$$varname"; // Prints "$foo"
print "${$varname}"; // Prints "bar"
?>
--was--
Note that normal variable variables will not be parsed in double-quoted strings. You'll have to
use the braces to make it work, to resolve the ambiguity. For example:
$varname = "foo";
$foo = "bar";
print $$varname; // Prints "bar"
print "$$varname"; // Prints "$foo"
print "${$varname}"; // Prints "bar"
http://php.net/manual/en/language.variables.variable.php