What is meant by $x=$y ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is meant by $x=$y ?

function p ($x , $y) { $x= $y // i dont get this $text = $y + $x; return $text; } echo p (3, "7"); I try to run the code and the answer is 14. Someone please explain me why?

3rd Aug 2017, 2:11 AM
Zareen Azara
Zareen Azara - avatar
1 Answer
+ 4
$x= $y: assign $y's value to $x, so $x="7" $y + $x = "7" + "7", addition will try to convert the values to numbers, so we'll have 7 + 7 = 14, this value is assigned to $text and return to the caller. echo print out the return value of function p (which is 14).
3rd Aug 2017, 3:09 AM
Bàng Tứ Cường
Bàng Tứ Cường - avatar