3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php echo "Strings are sometimes numbers?\n"; $number1 = "2sdfsdfjoi"; var_dump($number1 == 2); // = true (wat?) $number2 = "22sdfsdfjoi"; var_dump($number2 == 2); // = false (makes sense...) var_dump($number2 == 22); // = true (wat?) echo "Strings are always == true\n"; var_dump($number2 == true); // string = true (ugghh) echo "The triple equals === is the only way to be sure\n"; var_dump($number2 === 22); // === the only way to be sure.
based on k3Mgb
Output for 4.3.0 - 5.0.5, 5.1.1 - 7.2.0
Strings are sometimes numbers? bool(true) bool(false) bool(true) Strings are always == true bool(true) The triple equals === is the only way to be sure bool(false)
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/tOf3f on line 15
Process exited with code 255.