0
If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b? 
the answer to this question is give as 100 can any one please tell me how?
3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by elanorejoseph
0

I did a simple script and found that was not the case.

<?php
$a=5;
$b=$a;
echo $$b;
?>

Found that $$b will be blank because it will search for the variable $5 and it is impossible to make a variable with that name.

0
If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b? 
the answer to this question is give as 100 can any one please tell me how?
$a = 5;
$b = 'a';
echo $a;//will ehco 5
echo $b;//will echo a
echo $$b//will echo 5
// $$b = $a since $b has value a
0

$b=a, not $a

yes i know that, its common php interview question at the basic level.
But it has to be like -

$b = 'a'; 
//and not like below -
$b = a;

check this page it will help to understand it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.