That sounds like the name of a cow doesn't it? Good ole' Elseif just ain't makin' as much milk as she used to. But in fact, the Elseif statement does more than give milk. Elseif statements allow you to expand upon the Else statement. Just look at this table and it will be crystal clear: <html> <body> <?php $marry_who = "James"; if ( $marry_who == "James") { echo 'Now I am the both the Happiest and Fattest man alive!'; } else if ($marry_who == "Brad") { echo 'Jennifer Aniston is prettier than you!'; else { echo 'Who the hell is he?!?'; } echo 'I'm Brad Pitt's cousin, Fat Pitt.'; ?> </body> </html> There, that's more like it. Now we are forcing the buxom Tomb Raider to choose between me and her lackluster actor boyfriend (I refuse to accept the fact that they are married). Even though in my mind I know who she would pick (and you better too you monkeys), let's look at the results of this program: First we started off giving the variable $marry_who the value of "James." Then the program asks who she chose. Clearly, she chose me. And since the value of $marry_who is "James" the following prints out: Now I am both the Happiest and Fattest man alive! I'm Brad Pitt's cousin, Fat Pitt. Tada. Now if by some crazy luck, the star's were aligned in Brad Pitt's favor, it would have printed this: Jennifer Aniston is prettier than you! I'm Brad Pitt's cousin, Fat Pitt. And lastly, if Angelina has decided handsome, smart, funny, creatively brilliant men (me) and goofy, can't-act-his-way-out-of-a-paper-bag actors with a yawnable six-pack of abs (Brad Pitt) aren't her type, and she chooses some other fool, this would be there result: Who the hell is he?!? I'm Brad Pitt's cousin, Fatt Pitt. Again, since the line about me being Brad Pitt's cousin is outside of the statement, it will print regardless of the IF...Else...Elseif result.
blog comments powered by Disqus |
|
|
|
|
|
|
|