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