# Simple Math in PHP

by on June 19, 2008

Do some Math in PHP. Here is how to do Summation, Multiplication, Subtraction, Division, Power and more in PHP.

#### Summation

```<?php \$sum = 16 + 30; echo \$sum; ?>```
```<?php \$a = 26; \$b = 30; \$sum = \$a + \$b; echo \$sum; ?>```

#### Multiplication

```<?php \$a = 26; \$b = 30; \$c = 35; \$multiply = \$a*\$b*\$c; echo \$multiply; ?>```

#### Subtraction

```<?php \$a = 26; \$b = 30; \$sub = \$b-\$a; echo \$sub; ?>```

#### Division

```<?php \$a = 26; \$b = 30; \$divide = \$b/\$a; echo \$divide; ?>```

#### Power

```<?php \$a = 26; \$b = 30; \$power = Pow(\$a, \$b); echo \$power; ?>```

### Related Posts

• Simple PHP Script – Lets Start PHP – Echo Hello PHP If you want to learn PHP you have come to the right place. I will not only teach you how […]
• PHP Logical Operators Logical operators are true or false. NOT if(!1) Value is not one AND 4 && 4 […]
• PHP Functions A function is just a name we give to a block of code that can be executed whenever we […]
• PHP ForEach Loop PHP provides an easy way to use every element of an array with the For each statement. […]
• PHP Do While Loop A "do while" loop is a slightly modified version of the while loop. A do-while loop […]
• PHP While Loop The while keyword takes a condition in parentheses, and the code block that follows is […]
• Data Types In PHP Data types are many e.g. Boolean, Integer, Double (or float), String and there might be […]
• PHP Arrays An array is a data structure that stores one or more values in a single value. In more […]
• PHP Increment Operator Some of the most frequently used code in PHP or any programming language is the code […]
• PHP Switch Statement Examples With the use of the switch statement you can check for many conditions at once, and the […]

Previous post:

Next post: