提问人:ViDiVe 提问时间:7/21/2022 最后编辑:ViDiVe 更新时间:7/21/2022 访问量:48
举个简单的例子,PHP中的松散比较==和严格比较===?[复制]
Undestanding with an easy example the loose comparison == and strict comparison === in PHP? [duplicate]
答:
1赞
ViDiVe
7/21/2022
#1
这是一个简单的例子,可以理解松散比较和严格比较之间的区别
<?php
$var1 = 100;
$var2 = "100";
// loose comparison does not contemplate the data type
// so the integer 100 is equal to string "100"
$comparison = ($var1 == $var2); // true
var_dump($comparison);
// strict comparison contemplates the data type
// so the integer 100 is different to string "100"
$comparison = ($var1 === $var2); // false
var_dump($comparison);
评论