Reputation: 37
Wanted to turn value of variable into variable itself. I am not getting result as expected.
The code, I am getting PHP parse error as syntax error, unexpected '{' on the isset line.
$Firstname="Andy";
$item="Firstname";
if(isset(${$item})))
{ echo ${$item};
}
I would have expected output of ${$item} would be "Andy"
The code, I am getting PHP parse error as syntax error, unexpected '{' on the isset line.
Upvotes: 0
Views: 26
Reputation: 3094
You have syntax error. You have extra closing bracket )
Replace your code with the below code
$Firstname="Andy";
$item="Firstname";
if(isset(${$item}))
{
echo ${$item};
}
Upvotes: 1