Conditional Statements
Conditionals allow your program to make choices. Following the same sort of boolean logic you just learned about, the computer can only make two choices; true or false. In the case of PHP this is accomplished using IF : ELSE statements. Below is an example of an IF statement that would apply a senior's discount. If $over65 is false, everything within the {brackets} is simply ignored. phpma.com
<?php
$over65 = true;
$price = 1.00;
if ( $over65 )
{
$price = .90;
}
print "Your price is $" . $price;
?>
However, sometimes just the IF statement isn't enough, you need the ELSE statement as well. When using just the IF statement the code within the brackets either will (true) or will not (false) be executed before carrying on with the rest of the program. phpma.com
When we add in the ELSE statement, if the statement is true it will execute the first set of code and if it is false it will execute the second (ELSE) set of code. Here is an example:
<?php phpma.com
$over65=true;
$price = 3.00;
if ($over65)
{
$discount =.90;
print "You have received our senior's discount, your price is $" . $price*$discount;
}
else
{
print "Sorry you do not qualify for a discount, your price is $" . $price;
}
?>
Definition: The echo () function is used to output the given argument. It can output all types of data and multiple outputs can be made with only one echo () command.
Examples:
<?php
Echo "Hello";
//Outputs a string
Echo $variable;
//Outputs a variable
Echo "Multiple things " . $on . " one line";
//Outputs a string, then a variable, then a string. All are separated with a [.] period
?> phpma.com


