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"; } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 69
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 69
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 54
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
2 jumps found. (Code = 46) Position 1 = 57, Position 2 = 65
Branch analysis from position: 57
2 jumps found. (Code = 47) Position 1 = 59, Position 2 = 61
Branch analysis from position: 59
2 jumps found. (Code = 47) Position 1 = 62, Position 2 = 64
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 67
Branch analysis from position: 66
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 67
Branch analysis from position: 64
Branch analysis from position: 61
Branch analysis from position: 65
Branch analysis from position: 54
2 jumps found. (Code = 46) Position 1 = 57, Position 2 = 65
Branch analysis from position: 57
Branch analysis from position: 65
Branch analysis from position: 69
2 jumps found. (Code = 77) Position 1 = 76, Position 2 = 81
Branch analysis from position: 76
2 jumps found. (Code = 78) Position 1 = 77, Position 2 = 81
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 79, Position 2 = 80
Branch analysis from position: 79
1 jumps found. (Code = 42) Position 1 = 76
Branch analysis from position: 76
Branch analysis from position: 80
Branch analysis from position: 81
2 jumps found. (Code = 43) Position 1 = 91, Position 2 = 93
Branch analysis from position: 91
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 93
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 81
Branch analysis from position: 69
filename:       /in/T0pYJ
function name:  (null)
number of ops:  95
compiled vars:  !0 = $students, !1 = $scores, !2 = $studentName, !3 = $score1, !4 = $score2, !5 = $score3, !6 = $average, !7 = $totalMarks, !8 = $percentage, !9 = $subjectMarks, !10 = $failedSubjectsCount, !11 = $mark
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                       !0, <array>
   15     1        ECHO                                                         '%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A'
   16     2        ECHO                                                         '++++STUDENT+GRADE+PROCESSING+SYSTEM++++++%0A'
   17     3        ECHO                                                         '%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%0A'
   20     4      > FE_RESET_R                                           $13     !0, ->69
          5    > > FE_FETCH_R                                           ~14     $13, !1, ->69
          6    >   ASSIGN                                                       !2, ~14
   21     7        INIT_FCALL                                                   'strtoupper'
          8        SEND_VAR                                                     !2
          9        DO_ICALL                                             $16     
         10        CONCAT                                               ~17     '---+', $16
         11        CONCAT                                               ~18     ~17, '+---%0A'
         12        ECHO                                                         ~18
   23    13        FETCH_DIM_R                                          ~19     !1, 0
         14        ASSIGN                                                       !3, ~19
   24    15        FETCH_DIM_R                                          ~21     !1, 1
         16        ASSIGN                                                       !4, ~21
   25    17        FETCH_DIM_R                                          ~23     !1, 2
         18        ASSIGN                                                       !5, ~23
   28    19        ADD                                                  ~25     !3, !4
         20        ADD                                                  ~26     ~25, !5
         21        DIV                                                  ~27     ~26, 3
         22        ASSIGN                                                       !6, ~27
   31    23        ADD                                                  ~29     !3, !4
         24        ADD                                                  ~30     ~29, !5
         25        ASSIGN                                                       !7, ~30
   32    26        DIV                                                  ~32     !7, 300
         27        MUL                                                  ~33     ~32, 100
         28        ASSIGN                                                       !8, ~33
   34    29        CONCAT                                               ~35     'Scores%3A+', !3
         30        CONCAT                                               ~36     ~35, '%2C+'
         31        CONCAT                                               ~37     ~36, !4
         32        CONCAT                                               ~38     ~37, '%2C+'
         33        CONCAT                                               ~39     ~38, !5
         34        CONCAT                                               ~40     ~39, '%0A'
         35        ECHO                                                         ~40
   35    36        INIT_FCALL                                                   'number_format'
         37        SEND_VAR                                                     !6
         38        SEND_VAL                                                     2
         39        DO_ICALL                                             $41     
         40        CONCAT                                               ~42     'Average+Score%3A+', $41
         41        CONCAT                                               ~43     ~42, '%0A'
         42        ECHO                                                         ~43
   36    43        INIT_FCALL                                                   'number_format'
         44        SEND_VAR                                                     !8
         45        SEND_VAL                                                     2
         46        DO_ICALL                                             $44     
         47        CONCAT                                               ~45     'Percentage%3A+', $44
         48        CONCAT                                               ~46     ~45, '%25%0A'
         49        ECHO                                                         ~46
   39    50        IS_SMALLER_OR_EQUAL                                          50, !6
         51      > JMPZ                                                         ~47, ->54
   40    52    >   ECHO                                                         'Status%3A+PASS%0A'
   39    53      > JMP                                                          ->55
   42    54    >   ECHO                                                         'Status%3A+FAIL%0A'
   46    55    >   IS_SMALLER                                           ~48     90, !6
         56      > JMPZ_EX                                              ~48     ~48, ->65
         57    >   IS_SMALLER                                           ~49     95, !3
         58      > JMPNZ_EX                                             ~49     ~49, ->61
         59    >   IS_SMALLER                                           ~50     95, !4
         60        BOOL                                                 ~49     ~50
         61    > > JMPNZ_EX                                             ~49     ~49, ->64
         62    >   IS_SMALLER                                           ~51     95, !5
         63        BOOL                                                 ~49     ~51
         64    >   BOOL                                                 ~48     ~49
         65    > > JMPZ                                                         ~48, ->67
   47    66    >   ECHO                                                         'NOTICE%3A+Student+qualifies+for+the+Honor+Roll%21%0A'
   50    67    >   ECHO                                                         '%0A'
   20    68      > JMP                                                          ->5
         69    >   FE_FREE                                                      $13
   57    70        ECHO                                                         '%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A'
   58    71        ECHO                                                         '+++++ACADEMIC+PROBATION+EVALUATION+++++++%0A'
   59    72        ECHO                                                         '%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%0A'
   62    73        ASSIGN                                                       !9, <array>
   63    74        ASSIGN                                                       !10, 0
   66    75      > FE_RESET_R                                           $54     !9, ->81
         76    > > FE_FETCH_R                                                   $54, !11, ->81
   67    77    >   IS_SMALLER                                                   !11, 50
         78      > JMPZ                                                         ~55, ->80
   68    79    >   PRE_INC                                                      !10
   66    80    > > JMP                                                          ->76
         81    >   FE_FREE                                                      $54
   72    82        FRAMELESS_ICALL_2                implode             ~57     '%2C+', !9
         83        CONCAT                                               ~58     'Subject+Marks%3A+', ~57
         84        CONCAT                                               ~59     ~58, '%0A'
         85        ECHO                                                         ~59
   73    86        CONCAT                                               ~60     'Total+Failed+Subjects%3A+', !10
         87        CONCAT                                               ~61     ~60, '%0A%0A'
         88        ECHO                                                         ~61
   76    89        IS_SMALLER                                                   2, !10
         90      > JMPZ                                                         ~62, ->93
   77    91    >   ECHO                                                         'WARNING%3A+Student+is+placed+on+academic+probation.%0A'
   76    92      > JMP                                                          ->94
   79    93    >   ECHO                                                         'STATUS%3A+Student+is+in+good+academic+standing.%0A'
   81    94    > > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
154.71 ms | 862 KiB | 10 Q