Two identical lines, but different lengths. Cropped, peeled, etc.

I have two lines: one of them is generated by PHP and stored in a database with 128 characters. The generated string is emailed to the user and must enter a string.

Now for some reason, one of the users (testing with me) is 132 characters long through var_dump. When I have echothem, they are exactly the same. The same for var_dump. In addition to the number of characters. Where are these extra 4 (invisible) characters?

+4
source share
4 answers

to try

var_dump(bin2hex($str1));
var_dump(bin2hex($str2));

or

var_dump(htmlspecialchars($str1));
var_dump(htmlspecialchars($str2));

to check that another, once found, insert different bits here, so that we can find out what the difference is.

EDIT:

a &, &, , && - 4 . , , , & &.

+13

, UTF-8, iso-8859-1 .

utf_decode() , .

+1

, char, å, , .

0

@aularon , :

var_dump (htmlspecialchars ($ str1));

var_dump (htmlspecialchars ($ str2));

showed that he really was &on one and not on the other line.

To solve, I used htmlspecialchars_decode($str), and it did the trick.

0
source

Source: https://habr.com/ru/post/1763249/


All Articles