PHP If Statement

The if statement is used to execute a block of code if a condition is true.

Syntax

if (condition) {
    // code to be executed
}

Example of PHP If Statement

<?php
$x = 10;
if ($x > 5) {
    echo "x is greater than 5";
}
?>

Output:

x is greater than 5

Explanation: This example demonstrates the use of the if statement in PHP. If the condition is true, the code inside the if block is executed.