Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

Math Function Library

Tue Oct 28, 2008 2:00 pm

Code:


<?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>




Post a reply
  Related Posts  to : Math Function Library
 Online Math Tutor     -  
 Math GMAT GRE SAT Tutor Available     -  
 GMAT, GRE, SAT, Math Tutor     -  
 Library Sort     -  
 Image I/O library     -  
 PHP SOAP server returns array using NuSOAP Library     -  
 Java Library Database Management System Project     -  
 PHP SOAP server returns array using NuSOAP Library     -  
 simple Ajax library solving back button and bookmarks     -  
 php function     -  

Topic Tags

PHP Functions