Login | Register | FAQ
Anonymous

Else and Elseif?

+ Post a reply

2 posts Page 1 of 1


Else and Elseif?

by ZeniF » Mon May 20, 2013 8:55 pm

I don't understand the difference between Elseif and else. Why is it nessesery to use Elseif if you can just repeatedly use else?
User avatar

ZeniF

  • Posts: 3
  • Joined: Fri May 10, 2013 4:54 pm

Re: Else and Elseif?

by XainPro » Wed May 22, 2013 12:42 pm

well you can not repeatedly use ELSE and on ELSE you can not check any condition maybe this simple example will help you to understand why we use else if

<?php

$position = 6;

if($position == 1)
{ echo "you are 1st"; }
else if($position == 2)
{ echo "you are 2nd"; }
else if($position == 3)
{ echo "you are 3rd"; }
else { echo "you are not in first 3 positions"; }

?>

i hope this is self explanatory example code if you still need explanation then you can ask me :)
User avatar

XainPro

  • Posts: 3933
  • Joined: Fri Feb 17, 2012 8:10 pm


+ Post a reply

Page 1 of 1