PHP has both integer and float (decimal) number types. These two types can be classified under the generic title numbers.
Valid numbers can be anything like:   8,   258,   -37,   89.25,   -3.5785,   5.5e2
- Number-type values are never quoted. The numbers added within quotes are strings with numeric values.
PHP supports a maximum integer of around two billion on most platforms (UNIX and Windows). With numbers larger than that, PHP will automatically use a floating-point type.

### 1. Numbers and Operator

The mathematical operators are specific symbols that performs mathematical calculations.
Operators act on the variables and numbers presented in PHP instructions.

#### The standard mathematical (Arithmetic) operators

```<?php
\$x = 5;
\$y = \$x + 3;
echo \$y;                 // 8
?>
```
• Subtraction ( - )
```<?php
\$x = 5;
\$y = \$x - 3;
echo \$y;                 // 2
?>
```
• Multiplication ( * )
```<?php
\$x = 5;
\$y = \$x * 3;
echo \$y;                 // 15
?>
```
• Division ( / )
```<?php
\$x = 5;
\$y = \$x / 3;
echo \$y;                 // 1.6666666666667
?>
```
• Modulus (division remainder) ( % )
```<?php
\$x = 5;
\$y = \$x % 3;
echo \$y;                 // 2
?>
```
• Increment ( ++ )
```<?php
\$x = 5;
\$x++;             // Ecivalent with:  \$x = \$x + 1;
echo \$x;                 // 6
?>
```
• Decrement ( -- )
```<?php
\$x = 5;
\$x--;             // Ecivalent with:  \$x = \$x - 1;
echo \$x;                 // 4
?>
```

#### Assignment Operators

• ( = )
```<?php
\$x = 5;
\$y = \$x;
echo \$y;                 // 5
?>
```
• ( += )
```<?php
\$x = 5;
\$x += 3;             // Ecivalent with:  \$x = \$x + 3;
echo \$x;                 // 8
?>
```
• ( -= )
```<?php
\$x = 5;
\$x -= 3;             // Ecivalent with:  \$x = \$x - 3;
echo \$x;                 // 2
?>
```
• ( *= )
```<?php
\$x = 5;
\$x *= 3;             // Ecivalent with:  \$x = \$x * 3;
echo \$x;                 // 15
?>
```
• ( /= )
```<?php
\$x = 5;
\$x /= 2;             // Ecivalent with:  \$x = \$x / 2;
echo \$x;                 // 2.5
?>
```
• ( .= )
```<?php
\$x = 5;
\$x .= 3;             // Ecivalent with:  \$x = \$x . 3;
echo \$x;                 // 53
?>
```
• ( %= )
```<?php
\$x = 5;
\$x %= 2;             // Ecivalent with:  \$x = \$x % 2;
echo \$x;                 // 1
?>
```

The mathematical calculations in PHP, as in arithmetic, are taken into account the operators precedence (the order in which complex calculations are made). If you want to force the execution order, you must group clauses in parentheses. Check the fallowing example:
```<?php
\$x = 8 + 3 * 5 -2;
echo \$x;                  // 21 (first 3*5 [15], then adds 8 and substract 2 )

\$x = (8+3) * (5-2);
echo '<br />'. \$x;        // 33  (first 8+3  [11], then  5-2 [3], then makes the multiplication  11*3 [33] )
?>
```

### 2. PHP mathematical functions

Along with the arithmetic operators you can use PHP mathematical functions for more complex operations.
Here are some examples of functions:
• abs(x) - The absolute value of "x"
```<?php
\$x = abs(-3.5);            // \$x = 3.5;
\$y = abs(-4);              // \$y = 4;
?>
```
• ceil(x) - "x" rounded up to the next highest integer
```<?php
\$x = ceil(3.5);            // \$x = 4;
\$y = ceil(-8.5);           // \$y = -8;
?>
```
• floor(x) - "x" rounded to the next lowest integer
```<?php
\$x = floor(3.5);            // \$x = 3;
\$y = floor(-8.5);           // \$y = -9;
?>
```
• max(x, y, ...) - returns the highest of the parameter values
```<?php
\$x = max(5, 88, -12, 78.4);
echo \$x;                       // 88
?>
```
• min(x, y, ...) - returns the lowest of the parameter values
```<?php
\$x = min(5, 88, -12, 78.4);
echo \$x;                       // -12
?>
```
• number_format(x, d) - Turns a number into the more commonly written version, grouped into thousands using commas. Also, can set a specified number of decimal points, specified by "d" parameter:
```<?php
\$x = 35788;
\$x = number_format(\$x);
echo \$x;                   // 35,788

\$y = 35788.3;
\$y = number_format(\$y, 2);
echo '<br />'. \$y;                   // 35,788.30
?>
```
• pow(x, n) - "x" raised to the power of "n"
```<?php
\$x = pow(3, 4);
echo \$x;             // 81
?>
```
• sqrt(x) - The square root of "x" or the special value NAN for negative numbers
```<?php
\$x = sqrt(64);
echo \$x;             // 8
?>
```

#### Daily Test with Code Example

##### PHP-MySQL
Which tag adds a new line into a paragraph?
<b> <br> <p>
```First line ...<br>
Other line...```
Which CSS property can be used to add space between letters?
text-size word-spacing letter-spacing
```#id {
letter-spacing: 2px;
}```
What JavaScript function can be used to get access to HTML element with a specified ID?
getElementById() getElementsByTagName() createElement()
```var elm = document.getElementById("theID");
var content = elm.innerHTML;
Click on the "echo" correct instruction.
echo "CoursesWeb.net" echo "CoursesWeb.net"; echo ""CoursesWeb.net";
`echo "Address URL: http://CoursesWeb.net";`
Numbers and mathematical 0perators

#### Last accessed pages

1. Bubble Tanks 3 (29340)
2. Snowboard Challenge (639)
3. Flash Games - Free online Games (29732)
4. N (1276)
5. Triangles with CSS (2049)

#### Popular pages this month

1. Flash Games - Free online Games (1693)
2. Qwop (1371)
3. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (1218)
4. Tunnel Rush (1169)
5. Drag Racer V3 (877)