3v4l.org

run code in 500+ PHP versions simultaneously
<?php // ========================================================= // PART 1: ARITHMETIC OPERATIONS & LOOPING (5 STUDENTS) // ========================================================= // Array representing 5 students with 3 exam scores each $students = [ "Student 1" => [88, 92, 96], // Qualifies for Honor Roll "Student 2" => [45, 48, 42], // Fail status "Student 3" => [91, 85, 90], // High average, no score > 95 "Student 4" => [65, 72, 58], // Pass status "Student 5" => [30, 40, 50] // Fail status ]; echo "=========================================\n"; echo " STUDENT GRADE PROCESSING SYSTEM \n"; echo "=========================================\n\n"; // Task 2.3: Loop to process grades for 5 students foreach ($students as $studentName => $scores) { echo "--- " . strtoupper($studentName) . " ---\n"; $score1 = $scores[0]; $score2 = $scores[1]; $score3 = $scores[2]; // Task 1.1: Calculate average score $average = ($score1 + $score2 + $score3) / 3; // Task 1.2: Calculate percentage score out of 300 marks $totalMarks = $score1 + $score2 + $score3; $percentage = ($totalMarks / 300) * 100; echo "Scores: " . $score1 . ", " . $score2 . ", " . $score3 . "\n"; echo "Average Score: " . number_format($average, 2) . "\n"; echo "Percentage: " . number_format($percentage, 2) . "%\n"; // Task 2.1: Pass or Fail logic based on average score if ($average >= 50) { echo "Status: PASS\n"; } else { echo "Status: FAIL\n"; } // Task 2.2: Honor Roll evaluation logic if ($average > 90 && ($score1 > 95 || $score2 > 95 || $score3 > 95)) { echo "NOTICE: Student qualifies for the Honor Roll!\n"; } echo "\n"; } // ========================================================= // PART 2: ACADEMIC PROBATION CHECK (5 SUBJECTS) // ========================================================= echo "=========================================\n"; echo " ACADEMIC PROBATION EVALUATION \n"; echo "=========================================\n\n"; // Task 1.3: Input marks for 5 subjects for a sample student $subjectMarks = [42, 85, 48, 90, 35]; $failedSubjectsCount = 0; // Count subjects below 50 foreach ($subjectMarks as $mark) { if ($mark < 50) { $failedSubjectsCount++; } } echo "Subject Marks: " . implode(", ", $subjectMarks) . "\n"; echo "Total Failed Subjects: " . $failedSubjectsCount . "\n\n"; // Warning trigger if student fails more than 2 subjects if ($failedSubjectsCount > 2) { echo "WARNING: Student is placed on academic probation.\n"; } else { echo "STATUS: Student is in good academic standing.\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)
8.5.100.0090.00416.75
8.5.90.0100.00616.91
8.5.80.0070.00416.62
8.5.70.0060.00316.73
8.5.60.0150.00916.62
8.5.50.0060.00616.57
8.5.40.0050.00416.66
8.5.30.0040.00516.77
8.5.20.0150.00616.66
8.5.10.0110.00516.73
8.5.00.0110.00516.62
8.4.250.0070.00819.73
8.4.240.0090.00419.65
8.4.230.0070.00619.55
8.4.220.0110.01119.54
8.4.210.0130.01019.46
8.4.200.0110.00419.67
8.4.190.0090.00719.75
8.4.180.0100.00419.38
8.4.170.0070.00619.35
8.4.160.0100.00919.53
8.4.150.0110.00719.66
8.4.140.0150.00917.76
8.4.130.0140.01217.79
8.4.120.0100.01017.91
8.4.110.0140.01017.79
8.4.100.0150.00817.89
8.4.90.0180.00917.90
8.4.80.0110.00217.94
8.4.70.0120.00517.96
8.4.60.0140.00817.94
8.4.50.0190.00717.96
8.4.40.0130.00517.72
8.4.30.0060.00617.82
8.4.20.0060.00617.79
8.4.10.0040.00717.63
8.3.330.0110.00418.61
8.3.320.0160.00818.48
8.3.310.0130.01118.58
8.3.300.0110.00718.47
8.3.290.0140.00618.41
8.3.280.0150.00518.54
8.3.270.0120.00916.69
8.3.260.0140.00216.63
8.3.250.0130.01016.60
8.3.240.0160.00616.60
8.3.230.0140.00916.61
8.3.220.0120.01016.70
8.3.210.0190.00716.65
8.3.200.0070.00516.75
8.3.190.0050.00516.74
8.3.180.0090.00816.46
8.3.170.0100.00516.63
8.3.160.0100.00816.79
8.3.150.0100.00516.75
8.3.140.0150.00716.73
8.3.130.0110.00816.83
8.3.120.0060.00616.60
8.3.110.0180.00716.62
8.3.100.0150.00816.79
8.3.90.0070.00516.64
8.3.80.0070.00516.67
8.3.70.0110.00616.56
8.3.60.0110.00516.68
8.3.50.0150.00516.78
8.3.40.0160.00818.14
8.3.30.0160.00717.97
8.3.20.0160.00518.03
8.3.10.0070.00418.11
8.3.00.0100.00218.03
8.2.330.0120.01017.91
8.2.320.0100.01017.98
8.2.310.0060.01418.14

preferences:
47.19 ms | 847 KiB | 5 Q