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

Modulus : remainder of a math division
Math Functions
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



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>";




PHP video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer