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 »
Search
Categories
Read More
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 Functions
The real power of PHP comes from its functions. PHP has more than 1000 built-in functions, and...
By PHP Tutorial 2024-05-17 07:53:06 0 3K
Other
PHP Nested if Statement
Nested If You can have if statements inside if statements, this is...
By PHP Tutorial 2024-05-17 07:47:26 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
Other
PHP - $_SERVER
$_SERVER $_SERVER is a PHP super global variable which holds information about headers,...
By PHP Tutorial 2024-05-17 08:08:50 0 5K