PHP Math functions for addition, subtraction, multiplication & division
Addition of two variables storing numbers.
$a=5;
$b=6;
$c=$a+$b;
echo $c;
Subtraction.
$a=8;
$b=10;
$c=$a-$b;
echo $c;
Multiplication
$a=3;
$b=14;
$c=$a*$b;
echo $c;// output 42
Division
$a=3;
$b=14;
$c=$a/$b;
echo $c; //Output 0.21428571428571
The output of division can be formatted to required decimal places
Questions
Addition:
- How do you perform addition of two numbers in PHP?
- What is the addition operator used in PHP?
- Can you add variables of different data types in PHP using the addition operator?
- How can you add a constant value to a variable in PHP?
- Are there any limitations to the size or range of numbers that can be added in PHP?
Subtraction:
- How do you perform subtraction of two numbers in PHP?
- What is the subtraction operator used in PHP?
- Can you subtract variables of different data types in PHP using the subtraction operator?
- How can you subtract a constant value from a variable in PHP?
- Are there any limitations to the size or range of numbers that can be subtracted in PHP?
Multiplication:
- How do you perform multiplication of two numbers in PHP?
- What is the multiplication operator used in PHP?
- Can you multiply variables of different data types in PHP using the multiplication operator?
- How can you multiply a variable by a constant value in PHP?
- Are there any limitations to the size or range of numbers that can be multiplied in PHP?
Division:
- How do you perform division of two numbers in PHP?
- What is the division operator used in PHP?
- Can you divide variables of different data types in PHP using the division operator?
- How can you divide a variable by a constant value in PHP?
- Are there any limitations or considerations for dividing numbers in PHP, such as handling division by zero or precision of decimal values?
Modulus : remainder of a math division →
← Math Functions
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com
kakuyaw | 06-03-2015 |
What is the value is not given, or not been initialize? Then what if i want to display my answer in textbox? Any idea? |
smo | 13-03-2015 |
Textbox value can be connected to display variable $c
echo "<input type=text name=t1 value=$c>"; |