I have two strings, one is generated by PHP and stored in a database at 128 characters. The generated string is e-mailed to the user and they must input the string.
Now for some reason, the one from the user (with me testing), is 132 characters long through var_dump
. When I echo
them, they are exactly the same. Same thing for var_dump
. Except the character count. Where are these extra 4 (invisible) characters coming from?
try
var_dump(bin2hex($str1));
var_dump(bin2hex($str2));
or with
var_dump(htmlspecialchars($str1));
var_dump(htmlspecialchars($str2));
to inspect what's different, once found, paste here the different bits so we can figure out where the difference is from.
EDIT:
It's a &
encoded as &
notice that &
<-> &
are 4 chars different. what I think is going on is that you are sending a plain text emails, but entitizing the string, thus all &
are becoming &
.
Probably one is UTF-8 and one is iso-8859-1 or some other different encoding.
Try utf_decode() on one of them and see if it matches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With