0% found this document useful (0 votes)
15 views

PHP Tizag Tutorial-15

The document performs basic arithmetic operations like addition, subtraction, multiplication, division, and modulus using PHP code. It defines variables to store the operation results and uses echo statements to output the operations and results to the display. It then provides an example of using a modulus operation to get the remainder of 5 divided by 2.

Uploaded by

Anil Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

PHP Tizag Tutorial-15

The document performs basic arithmetic operations like addition, subtraction, multiplication, division, and modulus using PHP code. It defines variables to store the operation results and uses echo statements to output the operations and results to the display. It then provides an example of using a modulus operation to get the remainder of 5 divided by 2.

Uploaded by

Anil Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

PHP Code:

$addition = 2 + 4;
$subtraction = 6 - 2;
$multiplication = 5 * 3;
$division = 15 / 3;
$modulus = 5 % 2;
echo "Perform addition: 2 + 4 = ".$addition."<br />";
echo "Perform subtraction: 6 - 2 = ".$subtraction."<br />";
echo "Perform multiplication: 5 * 3 = ".$multiplication."<br />";
echo "Perform division: 15 / 3 = ".$division."<br />";
echo "Perform modulus: 5 % 2 = " . $modulus
. ". Modulus is the remainder after the division operation has been performed.
In this case it was 5 / 2, which has a remainder of 1.";

Display:
Perform addition: 2 + 4 = 6
Perform subtraction: 6 - 2 = 4
Perform multiplication: 5 * 3 = 15
Perform division: 15 / 3 = 5
Perform modulus: 5 % 2 = 1. Modulus is the remainder after the division operation has been
performed. In this case it was 5 / 2, which has a remainder of 1.

Comparison Operators

Comparisons are used to check the relationship between variables and/or values. If you would like to see
a simple example of a comparison operator in action, check out our If Statement Lesson. Comparison operators
are used inside conditional statements and evaluate to either true or false. Here are the most important
comparison operators of PHP.
Assume: $x = 4 and $y = 5;
Operator English Example Result
== Equal To $x == $y false
!= Not Equal To $x != $y true
< Less Than $x < $y true
> Greater Than $x > $y false
<= Less Than or Equal To $x <= $y true
>= Greater Than or Equal To $x >= $y false

You might also like