Math Function Library
<?php
function subtract($n1, $n2) {
return $n1 - $n2;
}
function add($n1, $n2) {
return $n1 + $n2;
}
function divide($n1, $n2) {
if($n2 == 0)
return -1;
else
return $n1 / $n2;
}
function multiply($n1, $n2)
{
return $n1 * $n2;
}
function to_pow($n1, $pow)
{
if($pow)
return $n1 * to_pow($n1, $pow - 1);
return 1;
}
print(to_pow(6, 1) . "<br />");
print(multiply(5, 10) . "<br />");
print(divide(5, 10) . "<br />");
print(subtract(10, 50) . "<br />");
print(add(10, 5) . "<br />");
?>
</body>
</html>
Related examples in the same category