Reputation: 1615
How does PHP handle something like this:
$blah = "Testing a variable";
$$blah = "test";
What would I access my dynamically declared variable?
Upvotes: 0
Views: 234
Reputation: 3621
Not really an answer, but...
<?php
function I_love_you()
{
return "haha";
}
$haha = "HoHoHo";
$tom = "I_love_you";
$blah = "tom";
echo ${$$blah()};
?>
Upvotes: 0
Reputation: 48897
echo ${'Testing a variable'};
However, you don't want to do this in practice. It makes for unmaintainable, bug-prone code.
Upvotes: 4
Reputation: 9857
The variable $blah
must contain a valid variable name.
This will tell you about variables: http://www.php.net/manual/en/language.variables.basics.php
Upvotes: 1
Reputation: 76945
Everything you need to know about variable variables at http://www.php.net/manual/en/language.variables.variable.php, except for one thing: don't use them.
Upvotes: 9