PHP Nested if Statement

0
4K

Nested If

You can have if statements inside if statements, this is called nested if statements.

ExampleGet your own PHP Server

An if inside an if:

$a = 13;

if ($a > 10) {
  echo "Above 10";
  if ($a > 20) {
    echo " and also above 20";
  } else {
    echo " but not above 20";
  }
}
Try it Yourself »
Căutare
Categorii
Citeste mai mult
Alte
PHP while Loop
The while loop - Loops through a block of code as long as the specified condition is...
By PHP Tutorial 2024-05-17 07:48:58 0 4K
Alte
PHP if...else Statements
PHP - The if...else Statement The if...else statement executes some code if a...
By PHP Tutorial 2024-05-17 07:46:12 0 4K
Alte
PHP Sorting Arrays
The elements in an array can be sorted in alphabetical or numerical order, descending or...
By PHP Tutorial 2024-05-17 08:06:46 0 8K
Alte
PHP foreach Loop
The foreach loop - Loops through a block of code for each element in an array or each...
By PHP Tutorial 2024-05-17 07:50:19 0 4K
Alte
PHP Break
The break statement can be used to jump out of different kind of loops. Break in For...
By PHP Tutorial 2024-05-17 07:50:37 0 5K
Sociallez https://sociallez.com