I came across this while playing with php
$test1 = '123abc';
$test2 = 123;
var_dump($test1); echo "<br />";
var_dump($test2); echo "<br />";
$test3 = ($test1 == $test2) ? True : False;
var_dump($test3);
This resulted in:
string(6) "123abc"
int(123)
bool(true)
Could someone explain why $test3 came out true?
using "===" would make that false but that would be due to comparing string to int.
Also notice if I force (string)$test2 it would give me the expected false, and forcing (int)$test1 returns the expected true;
Does this mean $test3 return true because PHP automatically converted $test1 into int before comparison?