My guess is that your strings have some characters that aren't visible.
Consider the following:
$a = "abc";
$b = "abc\0";
echo (int)( $a == $b );
This will echo 0
.
But, if you echo $a
and $b
, you will see "abc"
.
Another possibility might be that you are reading/writting a file using fopen()
without the b
option.
Windows has a feature that converts \r
and \n
into \r\n
.
When you read back, it comes with Windows' line endings.
When you compare, the values are different, since \r
(in memory/cookie) isn't the same as \r\n
(read from the file).
When you output it to a browser, it is shown as abc
. Browsers ignore whitespaces in the output (changeable with CSS).
Another thing might be implicit numeric convertion.
Consider the following code:
echo '1000000000000000000000000000000000000000000000000' == '1.0E+48';
This will echo 1
. Check it here: http://sandbox.onlinephpfunctions.com/code/1debf1a505793e3d0fde3b174c26e1f1454ea1e2
Using ===
solves this.
Something similar might be happening. But this shows the oposite (2 different strings that aren't equal being compared that returns true
).
The source and the environment itself are unknown.
How the values are obtained is unknown as well.
There are too many unknowns...