0
[PHP] Assignment Operator
Can anyone explain me what is wrong with the assignment operator ? For example i've encountered a challenge recently which was like this. $var = "hello"; $var += 6; echo $var; The answer was 6 But I really cannot get it. For what I've seen in internet, when there is += operator, it just makes like this. $x += 6 >>>>> $x = $x + 6 Then why the answer isin't 'hello 6' ???
4 Respostas
+ 2
Antonio Parroni the challenge isnt weird.
php is weird.
the challenge teaches you the weirdness of php
+ 1
php,php..php
a language of utmost weirdness.
the += operator is very unstable for string concatenation in php..
use "."
$var="hello";
$var=$var."6";
echo $var;
+ 1
Brains🇳🇬 haha, makes sense. Thanks
0
Brains🇳🇬 then why such a weird challenge like this is present in the system ?
This is just unfair 🤒