shadowline
Variables << Numbers - Math >> Numbers - Formatting
Numbers can be added, subtracted, multiplied, divided, put into variables, formatted, and so on.

<?php
$number = 10;
$number = $number + 1;
echo "$number";
?>

Outcome :
11

Math in PHP follows the same precedence rules as regular math. BEDMAS. From most important to least important is :
Brackets Exponents Division Muliplication Addition Subtraction

<?php
$first_number = 10 - 4 / 2;
$second_number = (10 - 4) / 2;
echo "$first_number <br />";
echo "$second_number";
?>

Outcome :
8
3



A simple shortcut method may be used to add or subtract 1 from a number.

<?php
$number = 10;
$number++;    // that is the same as saying $number=$number+1;
echo "$number";
?>

Outcome :
11

Can you guess what you would put to decrease a number by one? For those who are having a brain fuzzy :

<?php
$number = 10;
$number--;    // that is the same as saying $number=$number-1;
echo "$number";
?>

Outcome :
9
Variables << Numbers - Math >> Numbers - Formatting
shadow

Advertise in the banner along the top, Click here!

Valid XHTML 1.0 Transitional Valid CSS! Text Link Ads
shadow
shadow