echo "1" . (print '2') + 3; returns 214. How does the script end up with *14?
echo 1 . (print ‘2’) + 3; returns 214. How does the script end
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you do
PHP will do (demo)
In words:
and that’s 214.
The operators
+ - .have equal Operator Precedence, but are left associative:Edit: since all the other answers claim PHP does 1+3, here is further proof that it doesnt:
gives 220, e.g. 11+9 and not
1 . (1+9). If the addition had precedence over the concatenation, it would have been 2110, but for that you’d had to write