3v4l.org

run code in 300+ PHP versions simultaneously
<?php function battle($a, $b) { if ($a > 2 || $b > 2) { $a = (int)($a / 3); $b = (int)($b / 3); } return ($a - $b + 3) % 3; } $hand_list = array( 0 => 'グー', 1 => 'チョキ', 2 => 'パー', 3 => '奴隷', 6 => '皇帝', ); $result_list = array( 2 => 'あなたの勝ちです', 1 => 'あなたの負けです', 0 => 'あいこです', -1 => '不明', ); // 手が送信されたとき勝負を実行 if (isset($_POST['you'])) { // 整数型にキャスト(不正な値をエラー無しに防ぐ効果もある) $you = (int)$_POST['you']; // コンピュータの手を選出 $com = array_rand($hand_list); if (!isset($hand_list[$you])) { // 不正な値のときは自分の手を「?」、結果を「不明」にする $hand_list[$you = -1] = '?'; $result = -1; } else { // 正しい値のときは関数に渡す $result = battle($you, $com); } } // ヘッダー送信 header('Content-Type: application/xhtml+xml; charset=utf-8'); ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="ja"> <head> <title>じゃんけんゲーム</title> <style type="text/css"> label { display: block; } </style> </head> <body> <h1>じゃんけん</h1> <form action="<?=basename($_SERVER['SCRIPT_NAME'])?>" method="post"> <label><input type="radio" name="you" value="0" checked="checked" />グー</label> <label><input type="radio" name="you" value="1" />チョキ</label> <label><input type="radio" name="you" value="2" />パー</label> <label><input type="radio" name="you" value="6" />皇帝</label> <label><input type="radio" name="you" value="3" />奴隷</label> <label><input type="submit" value="勝負!" /></label> </form> <?php if (isset($result)): ?> <h1>勝負!</h1> <p> あなた: <?=$hand_list[$you]?><br /> コンピュータ: <?=$hand_list[$com]?><br /> <?=$result_list[$result]."\n"?> </p> <?php endif; //isset($result)がTrueのときだけ上記を表示できる ?> </body> </html>

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)
7.1.70.0060.00317.13
7.1.60.0130.01319.24
7.1.50.0160.01934.72
7.1.00.0030.03322.46
7.0.200.0000.00916.82
7.0.140.0000.07321.95
7.0.80.0330.04720.08
7.0.70.0100.07719.97
7.0.60.0030.04319.98
7.0.50.0100.04320.20
7.0.40.0000.08720.01
7.0.30.0130.07320.14
7.0.20.0030.06020.05
7.0.10.0000.08319.99
7.0.00.0100.08020.08
5.6.280.0000.07321.03
5.6.230.0000.08320.72
5.6.220.0130.07320.59
5.6.210.0100.07020.47
5.6.200.0070.08021.05
5.6.190.0070.08021.14
5.6.180.0100.07720.95
5.6.170.0070.06721.04
5.6.160.0030.08321.09
5.6.150.0070.07720.94
5.6.140.0070.08321.10
5.6.130.0100.07021.07
5.6.120.0000.05020.95
5.6.110.0070.05021.02
5.6.100.0070.07021.00
5.6.90.0100.08321.07
5.6.80.0070.07020.50
5.6.70.0130.07320.44
5.6.60.0000.07320.49
5.6.50.0130.06020.32
5.6.40.0100.03720.38
5.6.30.0130.06320.37
5.6.20.0030.04320.39
5.6.10.0070.08020.46
5.6.00.0000.08320.47
5.5.370.0030.04720.43
5.5.360.0130.07020.44
5.5.350.0070.05020.38
5.5.340.0130.06020.75
5.5.330.0070.08020.84
5.5.320.0100.04720.93
5.5.310.0000.05720.73
5.5.300.0100.08720.91
5.5.290.0130.08720.91
5.5.280.0200.04020.72
5.5.270.0070.08720.83
5.5.260.0070.07720.77
5.5.250.0170.07020.70
5.5.240.0070.05020.15
5.5.230.0130.07020.22
5.5.220.0130.06720.15
5.5.210.0100.04020.21
5.5.200.0070.05320.19
5.5.190.0070.04020.27
5.5.180.0030.04320.27
5.5.160.0100.07320.18
5.5.150.0070.07720.27
5.5.140.0170.06719.99
5.5.130.0030.06020.14
5.5.120.0130.04720.15
5.5.110.0030.07320.24
5.5.100.0030.04720.11
5.5.90.0130.05720.05
5.5.80.0030.07720.10
5.5.70.0100.06020.02
5.5.60.0030.08320.09
5.5.50.0130.07719.94
5.5.40.0130.07320.11
5.5.30.0100.07020.11
5.5.20.0070.03720.06
5.5.10.0070.07320.08
5.5.00.0070.06320.11
5.4.450.0070.08319.45
5.4.440.0070.05719.37
5.4.430.0030.04719.22
5.4.420.0070.05019.35
5.4.410.0000.05019.40
5.4.400.0130.07018.88
5.4.390.0000.06319.09
5.4.380.0070.07719.13
5.4.370.0100.07318.85
5.4.360.0000.07719.21
5.4.350.0030.06718.88
5.4.340.0030.08018.85
5.4.320.0100.04019.18
5.4.310.0030.06319.15
5.4.300.0030.04719.18
5.4.290.0030.08019.20
5.4.280.0070.06718.85
5.4.270.0030.08019.12
5.4.260.0100.04319.03
5.4.250.0070.07319.13
5.4.240.0000.05019.04
5.4.230.0130.04019.13
5.4.220.0030.07318.87
5.4.210.0070.07019.18
5.4.200.0070.07718.86
5.4.190.0030.07319.11
5.4.180.0030.07719.11
5.4.170.0070.08018.84
5.4.160.0170.06019.01
5.4.150.0070.08019.03
5.4.140.0100.07016.44
5.4.130.0070.05016.48
5.4.120.0130.03316.42
5.4.110.0000.08316.39
5.4.100.0070.06316.36
5.4.90.0070.06716.48
5.4.80.0130.04016.38
5.4.70.0030.04316.48
5.4.60.0070.06016.32
5.4.50.0200.05716.26
5.4.40.0070.04016.52
5.4.30.0130.06016.29
5.4.20.0030.06316.48
5.4.10.0070.08716.48
5.4.00.0100.05715.64
5.3.290.0100.06714.59
5.3.280.0070.05314.63
5.3.270.0070.07314.71
5.3.260.0030.04714.61
5.3.250.0070.05314.71
5.3.240.0200.06014.71
5.3.230.0000.07014.62
5.3.220.0100.03714.59
5.3.210.0100.05014.50
5.3.200.0070.05314.66
5.3.190.0030.04314.63
5.3.180.0070.07714.71
5.3.170.0030.04314.57
5.3.160.0170.05714.52
5.3.150.0030.08314.53
5.3.140.0070.07014.59
5.3.130.0070.07014.54
5.3.120.0070.07714.52
5.3.110.0100.07014.64
5.3.100.0100.03714.10
5.3.90.0000.07014.01
5.3.80.0000.04314.00
5.3.70.0070.03714.10
5.3.60.0130.06313.89
5.3.50.0070.07313.97
5.3.40.0100.04714.04
5.3.30.0130.05713.81
5.3.20.0000.06313.72
5.3.10.0130.06313.54
5.3.00.0030.04013.75
5.2.170.0030.04311.90
5.2.160.0070.03311.90
5.2.150.0030.05711.90
5.2.140.0030.02711.90
5.2.130.0130.05311.90
5.2.120.0000.03311.90
5.2.110.0030.06011.90
5.2.100.0070.05011.90
5.2.90.0070.02711.90
5.2.80.0000.03011.90
5.2.70.0030.03311.90
5.2.60.0070.05011.90
5.2.50.0100.05011.90
5.2.40.0100.05711.90
5.2.30.0030.06011.90
5.2.20.0070.03311.90
5.2.10.0000.03011.90
5.2.00.0000.03011.90
5.1.60.0030.03711.90
5.1.50.0070.05311.90
5.1.40.0030.03311.90
5.1.30.0070.05711.90
5.1.20.0100.03311.90
5.1.10.0000.03311.90
5.1.00.0030.05711.90
5.0.50.0100.03311.90
5.0.40.0000.02711.90
5.0.30.0000.05711.90
5.0.20.0000.02311.90
5.0.10.0070.03711.90
5.0.00.0030.03311.90
4.4.90.0030.02711.90
4.4.80.0000.02311.90
4.4.70.0000.04011.90
4.4.60.0000.02311.90
4.4.50.0000.02011.90
4.4.40.0030.05011.90
4.4.30.0030.03311.90
4.4.20.0000.02011.90
4.4.10.0030.03311.90
4.4.00.0030.05011.90
4.3.110.0030.03011.90
4.3.100.0000.02011.90
4.3.90.0030.01311.90
4.3.80.0070.05011.90
4.3.70.0030.02311.90
4.3.60.0100.02311.90
4.3.50.0030.02311.90
4.3.40.0000.03011.90
4.3.30.0070.03011.90
4.3.20.0030.03311.90
4.3.10.0000.02711.90
4.3.00.0000.02311.90

preferences:
36.93 ms | 400 KiB | 5 Q