I'm currently working through O'Reilly's "Programming PHP" and have come across this table titled "Type of comparison performed by the comparison operators":
First Operand | Second Operand | Comparison ----------------------------------------------------------------------- Number | Number | Numeric String that is numeric | String that is numeric | Numeric String that is numeric | Number | Numeric String that is not numeric | Number | Lexicographic String that is numeric | String that is not numeric | Lexicographic String that is not numeric | String that is not numeric | Lexicographic
My rule of thumb for which type of comparison is performed has been "numeric if and only if at least one operand is a number or both operands are numeric strings". This seems to be supported by the php.net page on Comparison Operators, which states "If you compare an integer with a string, the string is converted to a number. If you compare two numerical strings, they are compared as integers."
However, this would imply that the comparison in the fourth row of the table should be "Numeric". Does the table contain an error, or is my rule wrong?