title: PHP Type Juggling categories: [cheatsheets]
Reference: PHPMagicTricks-TypeJuggling.pdf
PHP has two main comparison modes, lets call them loose (==) and strict (===).
Comparing a string to an integer: "asomepass" == 1
For Example:
"asd1231" == int(0) : True
"abc" == int(0) : True
"0000" == int(0) : True
-> Even when having to strings that look like numbers, php converts both and does a number comparison
"0xF" == "15" : True ...
if the token starts with a letter or int(0), php will convert the token to an integer.
php > $a="0e1235432423";
php > $b="0e414512e12";
php > var_dump($a==$b);
-----------------------
bool(false)
-----------------------
php > var_dump($a===$b);
-----------------------
bool(false)
-----------------------
php > var_dump($a==$b);
-----------------------
bool(false)
-----------------------
php > $c=0e1231331;
-----------------------
php > var_dump($a==$c);
bool(true)
php > var_dump($b==$c);
bool(true)