Not knowing the reason of the answer found in challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Not knowing the reason of the answer found in challenge

$a = 'e'; $b = '2'; echo $a + $b; the output for this is 2. Can someone tell me the reason please?

19th Oct 2017, 11:13 PM
RanjOyHunTer
RanjOyHunTer - avatar
5 Answers
+ 5
It is because non-numerical parts of a string have no integer value. Hence, "e" is as good as "0" Edit: If a number is wedged between letters, it is considered non-numerical too
19th Oct 2017, 11:20 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
I am not so good in PHP so I verified ut on code playground
19th Oct 2017, 11:28 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
Glad it helped :)
19th Oct 2017, 11:27 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
thanks for the info Pegasus
19th Oct 2017, 11:27 PM
RanjOyHunTer
RanjOyHunTer - avatar
+ 1
you do your best 👍👍👍
19th Oct 2017, 11:30 PM
RanjOyHunTer
RanjOyHunTer - avatar