PHP if statement

We use PHP if statement to control the PHP program flow based upon conditions. It is used to route program execution. Here is the general form of if statement.
if(condition)
Statement;
Under the if statement the condition part returns a boolean value. If the condition is true then the statement is executed.
It is a single statement but if the statement is complex we must enclosed the statement or block of code with curly braces otherwise the second statement is executed (if the condition is true or not). Here’s the form is
if(condition)
{
Statement1;
Statement2;
………………..
}
Now we try to solve a problem with PHP if statement. Here, if Rahim‘s age is greater than 20, then it print Rahim is old boy.
<?php
$age=50;
If($age>20)
echo ” Rahim is old boy”;
?>

Comments

Popular posts from this blog

How to construct a B+ tree with example

How to show only month and year fields in android Date-picker?

Visitor Counter Script Using PHP