PHP If Statement

if statement is a fundamental control structure used to execute a block of code only if a specified condition evaluates to true.


Syntax of the if Statement:


if (condition) {
    // Code to be executed if condition is true
}
Example
<!DOCTYPE html>
<html>
<body>
<?php
if (19 >= 18) {
echo "You are eligible to vote.";
}
?>
</body>
</html>

Try it yourself

We can also use variables in the if statement:

Example
<!DOCTYPE html>
<html>
<body>
<?php
$age = 20;

if ($age >= 18) {
echo "You are eligible to vote.";
}
?>
</body>
</html>

Try it yourself


Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.