Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

php arithmetic

The document explains the arithmetic operators in PHP, detailing their functions such as addition, subtraction, multiplication, division, modulus, increment, and decrement. It provides an example using variables $a and $b to demonstrate each operator's usage and the expected output. The example shows the results of various arithmetic operations performed on the two numeric values.

Uploaded by

mdhasan.ansari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

php arithmetic

The document explains the arithmetic operators in PHP, detailing their functions such as addition, subtraction, multiplication, division, modulus, increment, and decrement. It provides an example using variables $a and $b to demonstrate each operator's usage and the expected output. The example shows the results of various arithmetic operations performed on the two numeric values.

Uploaded by

mdhasan.ansari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

In PHP, arithmetic operators are used to perform mathematical operations on

numeric values. The following table highligts the arithmetic operators that
are supported by PHP. Assume variable "$a" holds 42 and variable "$b" holds
20 −

Operator Description

+ Adds two operands

- Subtracts the second operand from the first

* Multiply both the operands

/ Divide the numerator by the denominator

% Modulus Operator and remainder of after an integer division

++ Increment operator, increases integer value by one

-- Decrement operator, decreases integer value by one

1.1 Example

The following example shows how you can use these arithmetic operators in
PHP −

Open Compiler

<?php
$a = 42;
$b = 20;

$c = $a + $b;
echo "Addtion Operation Result: $c \n";

$c = $a - $b;
echo "Substraction Operation Result: $c \n";

$c = $a * $b;
echo "Multiplication Operation Result: $c \n";

$c = $a / $b;
echo "Division Operation Result: $c \n";

$c = $a % $b;
echo "Modulus Operation Result: $c \n";

$c = $a++;
echo "Increment Operation Result: $c \n";

$c = $a--;
echo "Decrement Operation Result: $c";
?>
It will produce the following output −
Addtion Operation Result: 62
Substraction Operation Result: 22
Multiplication Operation Result: 840
Division Operation Result: 2.1
Modulus Operation Result: 2
Increment Operation Result: 42
Decrement Operation Result: 43

You might also like