1
2<?php
3if ($a > $b) {
4 echo "a is bigger than b";
5} elseif ($a == $b) {
6 echo "a is equal to b";
7} else {
8 echo "a is smaller than b";
9}
10?>
11
12
1
2easy way to execute conditional html / javascript / css / other language code with php if else:
3
4<?php if (condition): ?>
5
6html code to run if condition is true
7
8<?php else: ?>
9
10html code to run if condition is false
11
12<?php endif ?>
13
14
1$a = random_int(0, 10);
2$b = random_int(0, 10);
3if ($a > $b) {
4 echo 'a is greater than b';
5} elseif ($a == $b) {
6 echo 'a is equal to b';
7} else {
8 echo 'a is less than b';
9}