3v4l.org

run code in 300+ PHP versions simultaneously
<?php say("strcmp(): Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal. http://php.net/manual/en/function.strcmp.php"); # basic test string_lt('a', 'z'); # numeric strings string_lt('22', '123'); # non-numeric strings string_lt('bb', 'abc'); # non-numeric strings with numbers in # should be the same as "numeric strings" if strcmp() really does string comparison string_lt('22x', '123x'); function string_lt($str1, $str2) { # < operator if ($str1 < $str2) { say("$str1 < $str2"); } if ($str2 < $str1) { say("$str2 < $str1"); } # good old strcmp() if (strcmp($str1, $str2) { say("$str1 < $str2"); } if ($str2 < $str1) { say("$str2 < $str1"); } } function string_lt_old($str1, $str2) { # you can't use < operator for comparing strings # wacky stuff will happen $lt_says = ((string) $str1 < (string) $str2); # see what strcmp() says $strcmp_says = strcmp($str1, $str2); echo "$str1 less than $str2; lt_says: $lt_says, strcmp_says: $strcmp_says\n"; } function say(...$msgs) { foreach ($msgs as $msg) { echo $msg; } echo "\n"; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.320.1470.03719.21
5.4.310.1430.03719.32
5.4.300.1770.03319.21
5.4.290.1800.04719.21
5.4.280.1430.03719.02
5.4.270.1700.04318.75
5.4.260.1730.04319.05
5.4.250.1730.04018.99
5.4.240.1970.03719.21
5.4.230.1700.03718.77
5.4.220.2070.04019.22
5.4.210.1870.04719.20
5.4.200.1970.03319.07
5.4.190.2030.04318.99
5.4.180.2070.04319.20
5.4.170.1800.04318.88
5.4.160.2000.04319.29
5.4.150.1730.04319.09
5.4.140.1730.03716.50
5.4.130.1730.04016.51
5.4.120.1670.04316.33
5.4.110.1530.03316.55
5.4.100.1570.04716.19
5.4.90.1630.03716.54
5.4.80.1670.03716.54
5.4.70.1470.03716.50
5.4.60.1670.04716.36
5.4.50.1600.04316.33
5.4.40.1730.04316.54
5.4.30.1530.04016.34
5.4.20.1570.02716.52
5.4.10.1730.04316.52
5.4.00.1770.04015.92
5.3.290.1630.03314.68
5.3.280.1570.04714.65
5.3.270.1570.02714.72
5.3.260.1430.03714.59
5.3.250.1430.04314.62
5.3.240.1430.04014.59
5.3.230.2070.02714.58
5.3.220.1470.03714.48
5.3.210.1600.03314.47
5.3.200.1530.04014.55
5.3.190.1570.04014.62
5.3.180.1700.03014.55
5.3.170.1770.04014.68
5.3.160.1500.03714.79
5.3.150.1530.03714.46
5.3.140.2030.03314.64
5.3.130.1670.03714.48
5.3.120.1770.04014.45
5.3.110.1630.03714.66
5.3.100.1330.03314.07
5.3.90.1430.03314.00
5.3.80.1730.04314.03
5.3.70.1400.04013.93
5.3.60.1530.03714.03
5.3.50.1430.03314.01
5.3.40.1470.03314.18
5.3.30.1600.03713.83
5.3.20.1430.03713.59
5.3.10.1870.04013.77
5.3.00.1700.03313.79
5.2.170.1200.02711.16
5.2.160.1470.03011.08
5.2.150.1370.03011.18
5.2.140.1200.03011.15
5.2.130.1230.03311.26
5.2.120.1400.03311.25
5.2.110.1700.03711.05
5.2.100.1300.03011.11
5.2.90.1370.03311.00
5.2.80.0200.03711.15
5.2.70.0000.03711.12
5.2.60.0100.04011.06
5.2.50.1200.03311.17
5.2.40.0970.03010.91
5.2.30.1200.03710.98
5.2.20.0900.02711.21
5.2.10.1100.04010.95
5.2.00.1130.01710.87
5.1.60.1030.0239.98
5.1.50.0930.0309.93
5.1.40.1370.0309.86
5.1.30.1200.03010.27
5.1.20.1170.03010.50
5.1.10.1200.03710.23
5.1.00.1130.03310.25
5.0.50.0500.0208.47
5.0.40.0600.0208.57
5.0.30.0600.0278.35
5.0.20.0600.0238.19
5.0.10.0100.0338.08
5.0.00.0000.0508.05
4.4.90.0000.0207.78
4.4.80.0000.0337.78
4.4.70.0000.0337.78
4.4.60.0000.0237.78
4.4.50.0000.0207.78
4.4.40.0000.0307.78
4.4.30.0570.0237.78
4.4.20.0530.0277.78
4.4.10.0730.0237.78
4.4.00.0700.0377.78
4.3.110.0670.0207.78
4.3.100.0500.0177.78
4.3.90.0600.0237.78
4.3.80.0670.0377.78
4.3.70.0600.0177.78
4.3.60.0700.0107.78
4.3.50.0670.0177.78
4.3.40.0730.0407.78
4.3.30.0470.0307.78
4.3.20.0330.0177.78
4.3.10.0330.0137.78
4.3.00.0300.0137.78

preferences:
138.97 ms | 1394 KiB | 7 Q