Comparison of long numeric strings This post was last edited by anyilaoliu from 2013-12-1315: 04: 43 such as Question & nbsp; encountered such a problem $ a & nbsp; = & nbsp; "222111565652521142"; $ B & nbsp ;=& nbsp; "22211156565252113 comparison of long numeric strings
This post was last edited by anyilaoliu at 15:04:43, January 13 ,.
This problem occurs.
$a = "222111565652521142";
$b = "222111565652521139";
$c = 222111565652521142;
$d = 222111565652521139;
var_dump($a);
echo "
";
var_dump($b);
echo "
";
var_dump($c);
echo "
";
var_dump($d);
echo "
";
if ($a == $b) {
echo 3;
}else{
echo 31;
}
echo "
";
if ($c == $d) {
echo 4;
}else{
echo 41;
}
echo "
";
The result is
string '222111565652521142' (length=18)
string '222111565652521139' (length=18)
float 2.2211156565252E+17
float 2.2211156565252E+17
31
4
The question is, how can we compare the two in the second case?
Problem 2: The two groups of numbers read from the database are displayed as string (18) after var_dump, but the comparison result is the opposite of the above example, the comparison between the two strings is also passed.
Solution sharing: More