I got a question in an interview $a = '2'; $b = &$a; $b = '5$b'; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I got a question in an interview $a = '2'; $b = &$a; $b = '5$b';

What will be output $b?

18th May 2021, 2:12 PM
satyam sahay
satyam sahay - avatar
3 Answers
+ 1
In your code $b is 5$b . When you use $b = "5$b" #double quote Then $b will be 52
18th May 2021, 2:39 PM
TOLUENE
TOLUENE - avatar
+ 1
$b = &$a. Means $b is a reference variable of $a . Any changes made to $b will also change value of $a as $b is reference to $a
18th May 2021, 2:49 PM
TOLUENE
TOLUENE - avatar
0
What about &? In JavaScript it is bitwise operator..
18th May 2021, 2:46 PM
satyam sahay
satyam sahay - avatar