How to Install Operating System ??Complete Guide Installing The Operating System

PHP Arithmetic Operators

e-bookcomputer.com – Arithmetic Operators function as the name implies, namely for mathematical calculations, PHP Arithmetic Operators often use every day for addition, subtraction, division and so on. As we know the basic calculation symbols in the PHP programming language are not different, we should be familiar with this PHP Arithmetic Operators.

Before going forward, there are a number of articles that you might be looking for.

Read too :

PHP Arithmetic Operator Symbol

Here are some mathematical symbols that can be used to do calculations in the PHP programming language, You have to study seriously.

SymbolFunctionInformation
+AdditiveThis operator uses for the addition of two operands, for example a + b value;
-ReductionThis operator uses to subtract two operands, for example the value of a - b;
*MultiplicationThis operator uses to multiply two operands, for example the value of a * b (a x b);
/DivisionThis operator uses to divide two operands, for example the value of a / b;
%Mod (Modulus)This operator uses to generate the remaining value of the division, for example the value of a% b;

The symbols above are certainly not much different from what we often use every day to do basic calculations, then let’s look at an example of its use.

Implementation of PHP Arithmetic Operators

If you only see these symbols we will not know how to apply them in PHP programming languages, before please read the type of data type in PHP first, because no Data Types can be calculated using this PHP Arithmetic Operators.

<?php
     $a = 1 + 1;
     $b = 5-2.5;
     $c = 5 * 5;
     $d = 8/2;
     $e = 10% 6;
     echo '<h2> Calculation results with PHP </ h2>';
     echo 'Result 1 + 1 is'. $a;
     echo '<br />';
     echo 'Results 5 - 2.5 is'. $b;
     echo '<br />';
     echo 'Result 5 * 5 is'. $c;
     echo '<br />';
     echo 'Results 8/2 is'. $d;
     echo '<br />';
     echo 'Result 10 mod 6 is'. $e;
     echo '<h2> Type of data type results from the above calculation </ h2>';
     echo 'Data type from 1 + 1 is'; var_dump ($a);
     echo '<br />';
     echo 'Data types from 5 - 2.5 are'; var_dump ($b);
     echo '<br />';
     echo 'The data type of 5 * 5 is'; var_dump ($c);
     echo '<br />';
     echo 'Data type of 8/2 is'; var_dump ($d);
     echo '<br />';
     echo 'The data type of 10 mod 6 is'; var_dump ($e);
?>

From the above example, the calculation results will appear according to the arithmetic command of each function, from all the calculation results automatically PHP will read the data type according to each criterion, where we will be able to see it using the var_dump () function in PHP this is an example of its output.

PHP Arithmetic Operators
PHP Arithmetic Operators

Before proceeding, there are a number of articles that might be looking for.

Also read :

Sending
User Review
0 (0 votes)

Add a Comment

Your email address will not be published. Required fields are marked *