We have 14 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: / 0
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 708 listing and 43 categories in our website

Change Language

Free Advertising
Compare
Mortgage
Free Credit Scores
Advertising