Conditional Statements
The IF Statement (most used in all programming languages)
Syntax:
if (condition)
{
//Code to be executed
}
elseif (Condition)
{
}
else
{
}
Example:
<html>
<body>
<?php
$number=15;
if ($number ==15)
{
echo "The number is 15";
}
elseif ($number >16)
{
echo "The number is greater than 16";
}
?>
</body>
</html>
The if statement is the most used Conditional statement, in php the condition must be surrounded by ( ) if you will execute 1 line of code you don’t have to surround the code with { } but I strongly suggest that you always surround the code with { }.
No comments:
Post a Comment