codegurukool.com · Free coding tutorials & online compiler

Home › PHP Tutorial › PHP if...else...elseif

PHP if...else...elseif

Make decisions in code.

Combine conditions with && (and), || (or) and ! (not). Use === to compare value and type.

Example code

<?php
$score = 72;
if ($score >= 90) {
  echo "A";
} elseif ($score >= 70) {
  echo "B";
} else {
  echo "C";
}
?>

Run this code in the online editor

← PHP numbers and mathPHP switch and match →