+ 5
PHP code
How this possible bellow output? <?php $str1=10; $str2=20; $str3="15"-$str1; echo $str1+$str2/$str3; ?> // output 14
3 Respuestas
+ 3
This is due to operator precedence, Gauhar Rahman Niazi . First, the echo line checks the division of $str2 and $str3 (20 divided by 5 = 4). Only then it sums this result with $str1 (10+4). Hope it helps, even if so long afterwards.
+ 3
Thanks Abdul Moqueet
+ 2
Also the string "15" is implicitly converted to integer when doing calculations.