Number and String comparison in PHP (Numeric Values VS String Values)

<?php
if(0 == 'Cat')
{
    echo 1;
}
// outputs 1

if(0.1 > 'Cat')
{
    echo 1;
}
// outputs 1

# strings are converted into 0 when strings are compared (using '==' operator) with numeric values
?>

Comments

Popular posts from this blog

Timus 1209. 1, 10, 100, 1000... accepted solution in C

Timus Problem 1086. Cryptography Accepted Solution in C

Timus 1083. Factorials!!! Accepted Solution in C