Conditional Structures
Posted: Fri Jan 07, 2005 8:54 am
Conditional Statements
if/then/else
probably the most common of the conditional statements, throughout most major programming and scripting languages aswell as PHP, is the if/then/else statement.
the basic syntax for the if/then/else statement is:
[quote][/quote]
however, if you prefer to use a structure including braces { and }, the following syntax would be the most appropriate:
[quote][/quote]
script can be seen in action [url="http://ner0.killagraphix.com/php/evenorodd.php"]here[/url]
notice the '%' comparison operator, this is technically referred to as the modulus, it basically remainder of object1 devided by object2, in our case determining whether an object is even/odd...
more on comparison operators can be found at [url="http://www.php.net/manual/en/language.operators.php"]php.net/manual/en[/url]
and will probably be covered in a later how-to
if/then/else
probably the most common of the conditional statements, throughout most major programming and scripting languages aswell as PHP, is the if/then/else statement.
the basic syntax for the if/then/else statement is:
[quote][/quote]
however, if you prefer to use a structure including braces { and }, the following syntax would be the most appropriate:
[quote][/quote]
script can be seen in action [url="http://ner0.killagraphix.com/php/evenorodd.php"]here[/url]
notice the '%' comparison operator, this is technically referred to as the modulus, it basically remainder of object1 devided by object2, in our case determining whether an object is even/odd...
more on comparison operators can be found at [url="http://www.php.net/manual/en/language.operators.php"]php.net/manual/en[/url]
and will probably be covered in a later how-to