Monday, 17 February 2014

If_else If Statement in php

php if else if statement
if_ else if Statement in php
This is tutorial about if_else if statement.

Code for if_else if statement(Screenshot1):-

if_else if Statement in php
If_else If Statement Screenshot1

<?php
$number= 10;
if ($number==10) {
echo 'equal to ten.';
} else if ($number==11){
echo 'Equal to eleven.';
} else{
echo 'Not equal.';
}
?>

output (Screenshot2):-

If else if statement in php
Screenshot2
In “if_else statement” we can also evaluate one variables with many strings? For example we suppose
variable $number=10 in if_else statement as we did in “if statement”, its output will be equal to 10.
If value is 11 or any other value in “else_if statement”,it will echo out 11 if it is actually equal
to 11.Again in “else statement” if value is not equal to 10 niether 11 then it will echo out “Not
equal”. In this way you can evaluate many variables at a time with help of “if_else if_else
statement”.

Code for if_else if Statement(Screenshot3):-

if_else if Statement (Screenshot3)




<?php
$number= 11;
if ($number==10) {
echo 'equal to ten.';
} else if ($number==11){
echo 'Equal to eleven.';
} else{
echo 'Not equal.';
}
?>


output (Screenshot4):-

if_else if statement in php
Screenshot4

In this code of “if_else statement” it will execute because $number=11 is true. It will echo out
eleven.

Code for if_else if statement(Screenshot5):-

if_else if statement in php
Screenshot5

<?php

$number= 12;

if ($number==10) {

echo 'equal to ten.';

} else if ($number==11){

echo 'Equal to eleven.';

} else{

echo 'Not equal.';

}

?>


output(Screenshot6):-

if else if statement in php
Screenshot6
In this code of “if_else if_else statement” it will firstly compare values inside “if statement” and
“else_if statement ” and if the comparison is false ,thus will execute “else statement” because
variable is 12 and it is not equal to 10 or 11.


No comments:

Post a Comment

Thanks For Comment Will get you Soon..

About Me

Welcome to Extra Tutorials! My name is Mohammed and I am the 22 year writer, website developer, and photographer behind the blog. Thanks for visiting! Tutorials Jackpot… In addition to Developer, I love to develop websites and I love to write. Starting a php Blog was inevitable for me. What began as a simple way to share all of my Tutorials with friends and family has developed into my Part time job.

Mohammed Padela

WHAT IS PHP PROGRAMMING

WHAT IS PHP PROGRAMMING
WHAT IS PHP PROGRAMMING

Follow Us

Popular Posts

Designed ByBlogger Templates