3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $var1 = '123'; $var2 = '456A'; $var3 = '78'; $var4 = (int) $var2; $var5 = (float) $var2; $var6 = $var2 + 0; $var7 = 0 + $var2; comparevar("var1 and var2", $var1, $var2); comparevar("var2 and var3", $var2, $var3); comparevar("var3 and var2", $var3, $var2); comparevar("var3 and var1", $var3, $var1); comparevar("var2 and var1", $var2, $var1); comparevar("var4 and var5", $var4, $var5); comparevar("var5 and var6", $var5, $var6); comparevar("var6 and var7", $var6, $var7); comparevar("var2 and var4", $var2, $var4); comparevar("var3 and var4", $var3, $var4); comparevar("var2 and var5", $var2, $var5); comparevar("var2 and var6", $var2, $var6); function comparevar($tag, $arg1, $arg2) { echo("$tag: "); if ($arg1 === $arg2) { say("$arg1 === $arg2"); } if ($arg1 == $arg2) { say("$arg1 == $arg2"); } if ($arg1 < $arg2) { say("$arg1 < $arg2"); } if ($arg1 > $arg2) { say("$arg1 > $arg2"); } } function say($str) { echo $str, "\n"; }
based on ECMI7
Output for 7.1.0
Notice: A non well formed numeric value encountered in /in/bTjk6 on line 8 Notice: A non well formed numeric value encountered in /in/bTjk6 on line 9 var1 and var2: 123 < 456A var2 and var3: 456A < 78 var3 and var2: 78 > 456A var3 and var1: 78 < 123 var2 and var1: 456A > 123 var4 and var5: 456 == 456 var5 and var6: 456 == 456 var6 and var7: 456 === 456 456 == 456 var2 and var4: 456A == 456 var3 and var4: 78 < 456 var2 and var5: 456A == 456 var2 and var6: 456A == 456
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.14
var1 and var2: 123 < 456A var2 and var3: 456A < 78 var3 and var2: 78 > 456A var3 and var1: 78 < 123 var2 and var1: 456A > 123 var4 and var5: 456 == 456 var5 and var6: 456 == 456 var6 and var7: 456 === 456 456 == 456 var2 and var4: 456A == 456 var3 and var4: 78 < 456 var2 and var5: 456A == 456 var2 and var6: 456A == 456