PHP Nested if Statement

0
2K

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 »
Zoeken
Categorieën
Read More
Other
PHP - Concatenate Strings
String Concatenation To concatenate, or combine, two strings you can use...
By PHP Tutorial 2024-05-17 07:30:24 0 5K
Other
PHP if Operators
Comparison Operators If statements usually contain conditions that compare two values....
By PHP Tutorial 2024-05-17 07:45:46 0 2K
Other
PHP Global Variables - Superglobals
Superglobals were introduced in PHP 4.1.0, and are built-in variables that are always available...
By PHP Tutorial 2024-05-17 08:08:10 0 6K
Other
PHP Shorthand if Statements
Short Hand If To write shorter code, you can write if statements on one line....
By PHP Tutorial 2024-05-17 07:47:03 0 2K
Other
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 3K