Variables

\n"; //data type echo $list_price." is a "; echo gettype($list_price)."
\n"; echo $first_name."
\n"; echo $last_name."
\n"; echo $is_valid."
\n"; //true is 1 echo $is_new."
\n"; //false shows nothing ?>

Arithmetic Operators

\n"; $result = $x - $y; echo $x . " - " . $y . " = " . $result . "
\n"; $result = $x * $y; echo $x . " x " . $y . " = " . $result . "
\n"; $result = $x / $y; $result = number_format($result, 2); //round, 2 decimal places echo $x . " / " . $y . " = " . $result . "
\n"; $result = $x % $y; echo $x . " mod " . $y . " = " . $result . "
\n"; ?>

Date

\n"); $date = date('m/d/y'); echo($date."
\n"); $date = date('d/m/Y'); //British echo($date."
\n"); $date = date('M.d.Y'); echo($date."
\n"); $date = date('Y'); echo($date."
\n"); ?>

Relational Operators

\n"; } else { echo "$first is NOT equal to $second
\n"; } if (empty($investment)) //not declared { $message = "Investment is a required field."; echo $message."
\n"; } $investment = ""; //declared but empty if (empty($investment)) //not declared { $message = "Investment is a required field."; echo $message."
\n"; } ?>

Loops

\n"; $counter++; } echo "
\n"; $num = 200; do { echo "$num
\n"; $num = $num+1; } while ($num <= 206); echo "
\n"; for ($counter=1; $counter<=12; $counter=$counter+2) { echo "$counter
\n"; } echo "
\n"; for ($x=1; $x<=6; $x++) { for ($y=1; $y<=12; $y++) { echo $x.",".$y."; "; } echo "
\n"; } echo "
\n"; echo "

\n"; for ($x=1; $x<=6; $x++) { echo "\n"; for ($y=1; $y<=12; $y++) { echo "\t\n"; } echo "\n"; } echo "
"; echo $x.",".$y."; "; echo "
"; echo "
\n"; ?>