Why is integer 0 equal to a string in PHP?

casting, php, type-conversion, types

Solution

var_dump(0 == "string");

is doing a numeric (integer) comparison

0 is an integer, so "string" is converted to an integer to do the comparison, and equates to an integer value of 0, so 0 == 0 is true

Se the comparison with various types table in the PHP documentation for details

Problem

Possible Duplicate: How do the equality (== double equals) and identity (=== triple equals) comparison operators differ? Why this ``` var_dump(0 == "string"); ``` outputs this ``` bool(true) ``` Isn't the context of `==` operator supposed to convert `0` into `FALSE` and `"string"` into `TRUE` according to this set of rules?

Original source

Related problems