PHP: Conditional statements

This entry is part 24 of 54 in the series PHP Tutorial

The if conditional statement is one of the most important features of many languages, PHP included.

It allows for conditional execution of code fragments.

PHP features an if structure that is similar to that of C:

if (expression)

The following example would display a string ‘a is bigger than b’ if $a is bigger than $b:


$a = 20;
$b = 10;

if ($a > $b)
  echo "a is bigger than b";


Series Navigation<< PHP: Associative array
PHP: If else >>