Sunday, March 9, 2014

PHP if else statement.

if else statement has the following syntax:-


if(condition_0){
...
}else{
...
}

or

if(condition_0){
...
}elseif (condition_1){

}elseif (condition_2){

}else{
...
}

Example:


<html>
<head>
<title>Simple if/elseif example</title>
</head>
<body>
<?php
$Age = 22;
if ($Age < 10)
{
echo "You're under 10";
}
else if ($Age < 20)
{
echo "You're under 20";
}
else if ($Age < 30)
{
echo "You're under 30";
}
else if ($Age < 40)
{
echo "You're under 40";
}
else
{
echo "You're over 40";
}
?>
</body>
</html>

No comments:

Post a Comment