Exam 200-710 All QuestionsBrowse all questions from this exam
Question 9

What is the output of the following code?

    Correct Answer: A

    The given code snippet appears to be PHP code. In PHP, when you perform arithmetic operations on strings that contain integers or hexadecimal numbers, PHP attempts to convert these strings to their respective numeric values. The expression is evaluated according to the operator precedence rules, which prioritize multiplication over addition. Evaluating the expression step by step: The code is 'echo "1" + 2 * "0x02";', where the string '"0x02"' is interpreted as '0' because PHP encounters '0x' as a string prefix and ignores it. Therefore, the expression simplifies to '1 + 2 * 0', which results in '1'. Hence, the output of the code is '1'.

Discussion
[Removed]Option: A

in PHP 7.1 the result will be 1, so the correct answer is A

thuanptOption: C

echo "1" + 2 * "0x02"; // 1 echo 1 + 2 * 0x02; // 5

nicky91294Option: A

Answer is A