PHP Online Compiler
Example: PHP Script to Calculate Total Marks of Student and Display Grade
C
C++
C#
Java
Python
PHP
main.php
STDIN
Run
<?php $eng = 85; $hin = 78; $mar = 82; $math = 90; $it = 88; $total = $eng + $hin + $mar + $math + $it; $percentage = $total / 5; echo "Subject-wise Marks:<br>"; echo "English: $eng<br>Hindi: $hin<br>Marathi: $mar<br>Maths: $math<br>IT: $it<br>"; echo "Total: $total<br>Percentage: $percentage%<br>"; if ($percentage >= 90) { echo "Grade: A+"; } elseif ($percentage >= 75) { echo "Grade: A"; } elseif ($percentage >= 60) { echo "Grade: B"; } elseif ($percentage >= 50) { echo "Grade: C"; } else { echo "Grade: F"; } ?>
Output
Clear
ADVERTISEMENTS