In this tutorial I will give a brief lesson on the PHP if-then-else statement.
Keep in mind that I don't practice the proper 'formatting' of code (like indenting).
It doesn't matter, but it does make things easier for big projects.



This will check to see what $color is and return the proper results.
If $color is "red" then print "Red is a cool color!".
But, If $color is not "red", then print "That color isn't red!".

Now I'll go into a deeper version of the above example.



This will also check to see what $color is and return the proper results.
If $color is "red", then print "Red is a cool color!".
Or, If $color is not "green", then print "Green is also a cool color!".
And if $color isn't "red" or "green", then print "That color is $color.".

[Back To PHP Tutorials]
Free Web Hosting