+ 1

1.Why the output of the following programme is b ?

<?php $a="b"; $b="c"; $c="a"; for($i=0;$i<1;$i++) $c=$c; echo $c; ?>

27th Jul 2017, 3:29 PM
Md. Jahid Hasan
Md. Jahid Hasan - avatar
3 Respuestas
+ 12
Loop runs only once. So, $c = $c => $c = $($c) => $c = $(a) => $c = b
27th Jul 2017, 3:34 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 2
php has this neat thing where it can identify the name of a variable in the value of another. I this case, $c == a so $c would be $a And $a is initialized to "b" above.
27th Jul 2017, 3:33 PM
lion
lion - avatar
+ 1
it is because $c is like saying $(value_of_$c) --> $a --> b
27th Jul 2017, 3:33 PM
Matte
Matte - avatar