Note that php comparison is not transitive:
"php" == 0 => true
0 == null => true
null == "php" => false
![]() | 附录 O. PHP 类型比较表以下的表格显示了 PHP 类型和比较运算符在松散和严格比较时的作用。该补充材料还和类型戏法的相关章节内容有关。同时,大量的用户注释和 BlueShoes 的工作也给该材料提供了帮助。 在使用这些表格之前,需要明白变量类型及它们的意义。例如,"42" 是一个字符串而 42 是一个整数。FALSE 是一个布尔值而 "false" 是一个字符串。
表格 O-1. 用 PHP 函数对 $x 的比较
表格 O-2. 用 == 进行松散比较
表格 O-3. 用 === 进行严格比较
![]()
Jan
30-Dec-2005 03:23
Note that php comparison is not transitive:
php [at] barryhunter [.] co [.] uk
08-Sep-2005 03:44
In case it helps someone, here's a table to compare different Variable tests (created before I found this page!)
jerryschwartz at comfortable dot com
27-Jul-2005 04:04
In some languages, a boolean is promoted to an integer (with a value of 1 or -1, typically) if used in an expression with an integer. I found that PHP has it both ways:
tom
17-Jun-2005 05:27
<?php
aidan at php dot net
24-Jan-2005 11:00
The way PHP handles comparisons when multiple types are concerned is quite confusing. | ![]() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||