The php if statement is used to execute certain code if the condition is true. You can ask php to run the next code if a certain condition is a mention as you expected.

Example:

[php]<?php
$t = "25";

if ($t == "25") {
echo "Have a good day!";
}
?>[/php]

In the above code, the $t has assigned the value of 25. We have to ask php script to run the echo statement “Have a good day” if the $t matches the above variable.

In the code, if statement $t is matching the variable $25. It means the echo statement will render the given text successfully in the browser.

The outcome of the above statement will be.

Have a good day!

Related Posts

Leave a Reply