subtract two numbers in php

To subtract two numbers in PHP, you can use the subtraction operator (-) like this:

main.php
$num1 = 10;
$num2 = 5;
$result = $num1 - $num2;
echo $result; // Output: 5
75 chars
5 lines

In this example, the values of $num1 and $num2 are subtracted using the - operator and assigned to the $result variable. The value of $result is then printed to the screen using the echo statement.

You can substitute the values of $num1 and $num2 with any numerical values you wish to subtract.

related categories

gistlibby LogSnag