Example of Calculations in PHP
Php / / July 04, 2021
I leave a programming example in PHP. It works too simple, you just have to configure the two variables, $ FirstValue and $ SecondValue, currently they are at 10 and 30.
php
# Comments.
# Simple PHP programming example
# Doing simple calculations between predefined variables
# For ExampleDe. Com
$ FirstValue = 10; // Comment: Edit the number to change the first value
$ SecondValue = 30; // Comment: Edit the number to change the second value
// Calculation section
$ sum = $ FirstValue + $ SecondValue; // We add
$ subtraction = $ FirstValue - $ SecondValue; // We subtract
$ multiplication = $ FirstValue * $ SecondValue; // We multiply
$ division = $ FirstValue / $ SecondValue; // We divide
// Next we show the accounts in a textual format
echo " Textual Format
";
echo "The sum enter ". $ FirstValue." and
". $ SecondValue." is ". $ sum. "
";
echo "The subtraction between ". $ FirstValue." and
". $ SecondValue. " is ". $ subtracts. "
";
echo "The multiplication between ". $ FirstValue." and
". $ SecondValue." is ". $ multiplication."
";
echo" The division between ". $ FirstValue." and
". $ SecondValue." is ". $ division. "
"; // Next we show the accounts in a mathematical format
echo " Mathematical Format
";
echo "". $ FirstValue. "+". $ SecondValue. " = ". $ sum."
";
echo" ". $ FirstValue." - ". $ SecondValue." = ". $ subtract."
";
echo" ". $ FirstValue." * ". $ SecondValue." = ". $ multiplication."
";
echo" ". $ FirstValue." / ". $ SecondValue." = ". $ division."
";
This example in PHP would show the following
The sum Come in 10 Y 30 It is 40
The subtraction Come in 10 Y 30 It is -20
The multiplication Come in 10 Y 30 It is 300
The division Come in 10 Y 30 It is 0.333333333333
10 + 30 = 40
10 - 30 = -20
10 * 30 = 300
10 / 30 =0.333333333333