3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Question { public $text; public $points = 5; public $answers; public $correctAnswer; public $hint; } function createQuestions() { $questions = []; $q = new Question; $q->text = "Какая планета располагается четвертой по счету от Солнца?"; $q->points = 10; // 10 баллов за ответ $q->answers = array('a' => 'Венера', 'b' => 'Марс', 'c' => 'Юпитер', 'd' => 'Меркурий'); // Варианты ответа $q->correctAnswer = 'b'; // Правильный ответ $q->hint = "Красная планета"; $questions[] = $q; $q = new Question; $q->text = 'Какой город является столицей Великобритании?'; $q->points = 5; $q->answers = array('a' => 'Париж', 'b' => 'Москва', 'c' => 'Нью-Йорк', 'd' => 'Лондон'); $q->correctAnswer = 'd'; $q->hint = "Биг Бен"; $questions[] = $q; $q = new Question; $q->text = 'Кто придумал теорию относительности?'; $q->points = 30; $q->answers = array('a' => 'Джон Леннон', 'b' => 'Джим Моррисон', 'c' => 'Альберт Эйнштейн', 'd' => 'Исаак Ньютон'); $q->correctAnswer = 'c'; $q->hint = "Высунул язык"; $questions[] = $q; return $questions; } function printQuestions($questions) { $number = 1; foreach ($questions as $question) { echo "{$number}. {$question->text}\n"; echo "Варианты ответов:\n"; foreach ($question->answers as $letter => $answer) { echo " {$letter}. {$answer}\n"; } echo "\n"; $number++; } } function checkAnswers($questions, $answers) { if (count($questions) != count($answers)) { die("Число ответов и вопросов не совпадает\n"); } $pointsTotal = 0; $pointsMax = 0; $correctAnswers = 0; $totalQuestions = count($questions); for ($i = 0; $i < count($questions); $i++) { $question = $questions[$i]; // Текущий вопрос $answer = $answers[$i]; // текущий ответ $pointsMax += $question->points; if ($answer == $question->correctAnswer) { $correctAnswers ++; $pointsTotal += $question->points; } else { $number = $i + 1; echo "Неправильный ответ на вопрос №{$number} ({$question->text} Подсказка: $question->hint) \n"; } } echo "Правильных ответов: {$correctAnswers} из {$totalQuestions}, баллов набрано: $pointsTotal из $pointsMax\n"; } $questions = createQuestions(); printQuestions($questions); $answers = array('b', 'd', 'a'); checkAnswers($questions, $answers);

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)
8.3.60.0100.00716.50
8.3.50.0120.00317.98
8.3.40.0090.00618.91
8.3.30.0120.00318.83
8.3.20.0070.00021.82
8.3.10.0000.00821.82
8.3.00.0080.00020.70
8.2.180.0090.00618.30
8.2.170.0090.00622.96
8.2.160.0030.01021.27
8.2.150.0050.00325.66
8.2.140.0080.00024.66
8.2.130.0090.00326.16
8.2.120.0000.00719.72
8.2.110.0090.00021.03
8.2.100.0070.00417.84
8.2.90.0060.00317.84
8.2.80.0000.00818.16
8.2.70.0080.00017.63
8.2.60.0030.00617.63
8.2.50.0030.00517.49
8.2.40.0000.01118.16
8.2.30.0000.00719.23
8.2.20.0050.00318.17
8.2.10.0050.00318.89
8.2.00.0090.00019.44
8.1.280.0060.01325.92
8.1.270.0030.00720.85
8.1.260.0060.00326.35
8.1.250.0050.00228.09
8.1.240.0100.00023.83
8.1.230.0080.00321.04
8.1.220.0050.00317.74
8.1.210.0030.00518.78
8.1.200.0040.00417.23
8.1.190.0040.00417.25
8.1.180.0000.00918.10
8.1.170.0000.00817.62
8.1.160.0040.00419.05
8.1.150.0000.00718.84
8.1.140.0000.00817.41
8.1.130.0000.00720.12
8.1.120.0060.00317.56
8.1.110.0050.00217.50
8.1.100.0000.00717.54
8.1.90.0050.00217.53
8.1.80.0070.00017.49
8.1.70.0030.00517.39
8.1.60.0030.00517.64
8.1.50.0050.00517.61
8.1.40.0000.00817.41
8.1.30.0040.00717.52
8.1.20.0000.00817.71
8.1.10.0040.00417.49
8.1.00.0060.00317.52
8.0.300.0050.00320.03
8.0.290.0000.00716.75
8.0.280.0030.00318.55
8.0.270.0030.00316.77
8.0.260.0070.00020.15
8.0.250.0070.00017.00
8.0.240.0000.00717.03
8.0.230.0000.00716.96
8.0.220.0000.00716.94
8.0.210.0070.00016.82
8.0.200.0030.00316.90
8.0.190.0000.00716.88
8.0.180.0040.00416.98
8.0.170.0050.00316.95
8.0.160.0000.00816.91
8.0.150.0050.00316.75
8.0.140.0040.00416.89
8.0.130.0030.00313.32
8.0.120.0040.00416.89
8.0.110.0040.00416.82
8.0.100.0030.00516.98
8.0.90.0000.00816.95
8.0.80.0120.00316.98
8.0.70.0000.00816.92
8.0.60.0000.00716.73
8.0.50.0070.00016.78
8.0.30.0100.00617.11
8.0.20.0060.01517.35
8.0.10.0000.00816.95
8.0.00.0110.00717.02
7.4.330.0040.00015.55
7.4.320.0000.00716.50
7.4.300.0040.00416.54
7.4.290.0000.00816.61
7.4.280.0040.00416.68
7.4.270.0050.00216.63
7.4.260.0000.00713.36
7.4.250.0070.00216.36
7.4.240.0000.00716.49
7.4.230.0070.00016.38
7.4.220.0030.00416.55
7.4.210.0140.00616.60
7.4.200.0000.00716.34
7.4.130.0070.01116.59
7.4.120.0110.00616.56
7.4.110.0080.00816.59
7.4.100.0090.00916.37
7.4.90.0120.00616.63
7.4.80.0060.01219.39
7.4.70.0060.01016.53
7.4.60.0080.00816.52
7.4.50.0070.00716.39
7.4.40.0100.00716.56
7.4.00.0080.01014.87
7.3.330.0080.00016.44
7.3.320.0000.00613.25
7.3.310.0030.00316.41
7.3.300.0030.00316.25
7.3.290.0040.00416.41
7.3.280.0100.01016.35
7.3.260.0130.00716.52
7.3.240.0080.01016.45
7.3.230.0000.01716.42
7.3.210.0060.00916.46
7.3.200.0150.00316.66
7.3.190.0100.00716.51
7.3.180.0100.01016.36
7.3.170.0060.01016.43
7.3.160.0160.00016.33
7.3.120.0000.01814.83
7.3.110.0060.01214.88
7.3.100.0100.00514.79
7.3.90.0110.00514.77
7.3.80.0090.00814.87
7.3.70.0080.00614.79
7.3.60.0070.00914.74
7.3.50.0110.00614.95
7.3.40.0100.00514.89
7.3.30.0060.00814.63
7.3.20.0090.00415.65
7.3.10.0080.00915.83
7.3.00.0060.00815.85
7.2.330.0080.01116.88
7.2.320.0150.00616.88
7.2.310.0070.01116.55
7.2.300.0090.01216.54
7.2.290.0100.00816.70
7.2.250.0040.01315.38
7.2.240.0110.00715.08
7.2.230.0060.00915.06
7.2.220.0030.01515.35
7.2.210.0070.01015.03
7.2.200.0130.00515.01
7.2.190.0050.01314.99
7.2.180.0090.01015.07
7.2.170.0080.00615.09
7.2.160.0100.00414.87
7.2.150.0050.00916.06
7.2.140.0080.01015.99
7.2.130.0090.00715.87
7.2.120.0090.00516.03
7.2.110.0030.01115.89
7.2.100.0040.00715.98
7.2.90.0050.01016.05
7.2.80.0070.00715.98
7.2.70.0050.01016.10
7.2.60.0070.00815.94
7.2.50.0080.00716.10
7.2.40.0060.00816.06
7.2.30.0070.00515.84
7.2.20.0050.01016.15
7.2.10.0090.00816.03
7.2.00.0030.01415.90
7.1.330.0080.01015.09
7.1.320.0100.01014.85
7.1.310.0060.00914.79
7.1.300.0050.01115.02
7.1.290.0090.00714.97
7.1.280.0070.00514.75
7.1.270.0110.00214.87
7.1.260.0090.00514.85
7.1.250.0100.00714.78
7.1.240.0090.00315.60
7.1.230.0030.01015.97
7.1.220.0080.00815.77
7.1.210.0100.00715.67
7.1.200.0130.00016.00
7.1.190.0060.00615.68
7.1.180.0030.01015.91
7.1.170.0030.00615.76
7.1.160.0060.00315.55
7.1.150.0030.01015.86
7.1.140.0100.00715.93
7.1.130.0130.00615.80
7.1.120.0060.01215.92
7.1.110.0070.00716.00
7.1.100.0090.00315.99
7.1.90.0000.01315.97
7.1.80.0040.01115.80
7.1.70.0000.01315.71
7.1.60.0070.00315.63
7.1.50.0090.00015.95
7.1.40.0000.01415.79
7.1.30.0000.01215.82
7.1.20.0030.01015.76
7.1.10.0070.00715.89
7.1.00.0040.00415.55

preferences:
59.56 ms | 400 KiB | 5 Q