PHP if statement – this statement is used to execute a specific programming code if a specified condition is true.
The if statement
Used to execute a specific programming code if a specified condition is true. An if statement can be constructed without the else clause
Syntax:
if (condition) code to be executed if condition is true;
Here is an example of if statement:
<?php $name = "Piolo"; if ( $name == "Piolo" ) { echo "Welcome Piolo!<br />"; } echo "you’re not Piolo"; ?>
Result:
The result would be Welcome Piolo! If you change the value of name the output would be you’re not Piolo.