What is the result of executing following code?
echo 'foo' . 42 + 'bar' . 'qwe';
Explanation

"+" and "." operators has the same priority. "+" operator converts string values to number, 'foo42' + 'bar' = 0;

Operations are performed in order from left to right. In addition, each time there is a types juggling:
1) 'foo' . 42 => 'foo' . '42' => 'foo42'
2) 'foo42' + 'bar' => 0 + 0 => 0
3) 0 . 'qwe' => '0' . 'qwe' => '0qwe'

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes