Home > Backend Development > PHP Tutorial > 较长数字 字符串 的比较有关问题

较长数字 字符串 的比较有关问题

WBOY
Release: 2016-06-13 12:31:14
Original
734 people have browsed it

较长数字 字符串 的比较问题

本帖最后由 anyilaoliu 于 2013-12-13 15:04:43 编辑 如题 
遇到这样的问题

<br />
$a = "222111565652521142";<br />
		$b = "222111565652521139";<br />
		$c = 222111565652521142;<br />
		$d = 222111565652521139;<br />
<br />
		var_dump($a);<br />
		echo "<br/>";<br />
		var_dump($b);<br />
		echo "<br/>";<br />
		var_dump($c);<br />
		echo "<br/>";<br />
		var_dump($d);<br />
		echo "<br/>";<br />
<br />
		if ($a == $b) {<br />
			echo 3;<br />
		}else{<br />
			echo 31;<br />
		}<br />
		echo "<br/>";<br />
<br />
		if ($c == $d) {<br />
			echo 4;<br />
		}else{<br />
			echo 41;<br />
		}<br />
		echo "<br/>";<br />
Copy after login


结果是


<br />
<br />
<br />
string '222111565652521142' (length=18)<br />
<br />
<br />
string '222111565652521139' (length=18)<br />
<br />
<br />
float 2.2211156565252E+17<br />
<br />
<br />
float 2.2211156565252E+17<br />
<br />
<br />
<br />
31<br />
4<br />
Copy after login


问题来了,第二种情况 如何进行两者的比较

问题二: 从数据库中读出来的这两组数字,var_dump后显示是string(18)  但是比较结果和上边的例子恰好相反,两个string的 比较相等 也通过了.

求解
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template