Arithmetic Operators:
These are the most basic kind of operators. The PHP Arithmetic operator is used to perform addition(+), subtraction(-), Division(/), Multiplication(*), modulus(%). with variable or value. We all have done in our school days, and some of us have practiced in different languages, syntax is almost same as other languages. Different examples will try to make it clear:
Example (Unary Operator):
<?php
$a
=-12;echo
$a."<br/>";$a
=-$a;echo
$a."<br/>";$a
++;echo
$a."<br/>";echo
$a--."<br/>";echo
--$a."<br/>";?>
Output:
-12
12
13
13
11
Example (Binary operator):
<?php
$a
=-12+34-45/5*4;echo
$a;?>
Output:
-14
Example (Binary operator):
<?php
$a
=12;echo
$a/6 ."<br/>";echo
$a%5 ."<br/>";echo
$a*3 ."<br/>";echo
5+5 ."<br/>";echo
4-4 ."<br/>";?>
Output:
2
2
36
10
0
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.