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

If - 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.

TABLE OF CONTENTS:
  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
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

People are always asking what if. What if I weren't the world's fattest man? What if I poured vodka into that Kool-Aid guy's body -- would he get drunk? I mean technically the dude is already wired. Why else would he just crash through people's wall and yell his name?

As I said before, we already previewed the IF statement in our previous article. However, I will show it to you one more time here, just as a refresher. The basic idea of an If statement is: If this, do that.


<html>

<body>


<?php


$your_name = "Angelina Jolie";


if ( $your_name == "Angelina Jolie") {

echo 'Will you marry me?';

}


?>


</body>

</html>

In the above code, we store the name "Angelina Jolie" in a variable. We then say that if the value in $your_name is in fact "Angelina Jolie" print the line:

  Will you Marry me?

If the value of $your_name had been any other value, nothing would have happened.

But what good is that program if we don't get an answer? For that, let's use the If...Else statement.



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- 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: