condition

Estimated reading time: 1 minute

if

$a = 5;
if ($a === 5) {
  echo "${a}";
}
# 5

else

$a = 6;
if ($a === 5) {
  echo "${a}";
} else {
  echo "not 5"
}
# 5

elseif

$a = 6;
if ($a === 5) {
  echo "${a}";
} elseif ($a == 6) {
  echo "${a}"
} else {
  echo "not exist"
}
# 6

tenary condition

$a = 6;
$status = $a === 5 ? 'true' : 'false';
echo $status;
# false

resources

php