This may sound confusing:
$myVar = "Helloooo!";
$text = "myVar";
How could i call $myVar
from just the fact $text
is filled with the variable name, perhaps this ? (it doesnt work though)
echo $($text);
All help appreciated!!
This may sound confusing:
$myVar = "Helloooo!";
$text = "myVar";
How could i call $myVar
from just the fact $text
is filled with the variable name, perhaps this ? (it doesnt work though)
echo $($text);
All help appreciated!!
Use $$text
.
You wrote it with parenthesis, which is not the correct syntax.
PHP has a feature called "variable variables", that works exactly like you need it to.
You can use it almost like you posted, but without the brackets:
echo $$text;
The best notation is using curly braces however, as that removes ambiguities when dealing with arrays.
echo ${$text};