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
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap

Dev Shed Tutorial Topics: