Why does 1234 == '1234 test' evaluate to true?

equality, equals, php

Solution

Because you are using the == (similarity) operator and PHP is coercing the string to an int.

To resolve it use the === (equality) operator, which checks not only if the value is the same, but also if the data type is the same, so "123" string and 123 int won't be considered equal.

Problem

Possible Duplicate: php == vs === operator An easy answer for someone I'm sure. Can someone explain why this expression evaluates to true? ``` (1234 == '1234 test') ```

Original source