Patrick
Patrick

Reputation: 4905

php string - same and yet not the same

Basically I have 2 strings. They are EXACTLY the same string. However, when I do if ($a == $b) it says they are different. I print them out, they are exactly the same I see on browser.

The string's a password, $a can login but $b cannot login. What gives? Weird!

Upvotes: 0

Views: 83

Answers (3)

mitch
mitch

Reputation: 46

if (trim($a) == trim($b))

Upvotes: 3

thomasmalt
thomasmalt

Reputation: 1752

Have you tried viewing the strings in a debugger, or compare white space.

Upvotes: 0

user180100
user180100

Reputation:

Maybe there are some "blanks" in one of the string you don't see when printing on browser. Printing '>' . $a . '<' and same for $b might help.

Upvotes: 1

Related Questions