We have 38 guests online
PHP Scripts arrow Free PHP Tutorials arrow Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP 
Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP

Nested functions
User Rating: / 3
PoorBest 

An example of using functions embedded within functions. (Courtesy apress.com)

  1. <?php
  2.    function salestax($price,$tax) {
  3.       function convert_pound($dollars, $conversion=1.6) {
  4.          return $dollars * $conversion;
  5.       }
  6.       $total = $price + ($price * $tax);
  7.       echo "Total cost in dollars: $total. Cost in British pounds: ".convert_pound($total);
  8.    }
  9.  
  10. salestax(15.00,.075);
  11. echo convert_pound(15);
  12.  
  13. ?>

 

 

Directory Stats

There are 1036 listing and 46 categories in our website

Change Language