0
I came across this problem and conflicted, when using '+' in Javascript it "joins" and in PHP it gives me a number (Hi?), well the intention is to adapt the Javascript with PHP, see:
alert(CryptoJS.SHA1('ABCDE' + 'ABCD'.substr(0, 32)));
result: 64b9885c4ab720cabee37f0011aeb06efa27f9b3
In PHP I run the "same" thing, but returns something different:
echo SHA1('ABCDE' + substr('ABCD', 0, 32));
result: b6589fc6ab0dc82cf12099d1c2d40ab994e8410c
Why? What is the explanation for this and how to adapt Javascript?
the intention is to adapt JS to PHP.. and why is this happening? I need to understand so as not to make more mistakes.. Obg!
– Vinícius Lara
It’s happening because each of these languages has a different operator to work with string concatenation. It’s not a matter of fitting, one uses the "dot" and the other the "plus sign", that’s all.
– NovoK
The concatenation operators are different for each language. php the operator is . while in js is the +
– Sam