Home arrow PHP arrow Page 3 - PHP Statements and Beginning Loops

Else - PHP

We discussed statements briefly in our last article and even got a sneak peek of an IF-statement. Sure I mean, the image was blurry, and the moment it saw us it ran off into the forest. But we saw it. Honest. So in this article, we're going to take a much closer look at PHP statements and even start learning about loops.

  1. PHP Statements and Beginning Loops
  2. If
  3. Else
  4. Elseif
  5. Here We Go Loop de Loop
  6. For Loop
By: James Payne
Rating: starstarstarstarstar / 5
November 05, 2007

print this article






$your_answer = "Yes";

if ( $your_name == "Yes")


echo Now I am the both the Happiest and Fattest man alive!';




echo 'Jennifer Aniston is prettier than you!';


echo 'I'm Brad Pitt's cousin, Fat Pitt.';




Several things to note about the above code: 1) Jennifer Aniston is not hotter than Angelina Jolie, unless Jennifer Aniston or her lawyer are reading this, in which case she is very hot and a great actress to boot 2) If the value in $your_answer is equal to Yes, then the following will print:

  Now I am both the Happiest and Fattest man alive!

  I'm Brad Pitt's cousin, Fat Pitt.

If the value in $your_answer had not been Yes, this would have printed:

  Jennifer Aniston is prettier than you!

  I'm Brad Pitt's cousin, Fat Pitt.

Note that either way the line: I'm Brad Pitt's cousin, Fat Pitt prints out. This is because that echo is placed outside of the IF...Else statement and prints regardless of whether the criteria is met.

>>> More PHP Articles          >>> More By James Payne

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: