Home >> PHP - MySQL Creasting Dynamic Web Sites 3.1 [Page 3] Article by: Shelton Manage Tuesday, 09th June, 2009
Setting default argument values
Another variant on defining your own functions is to preset an argument's value. function function_name ($arg1, $arg2 = 'Shelee') { // Function code. }
To set default argument values
Open handle_calculator.php and change the function definition line, so that only the quantity is required argument.
function calculator_total ($quantity, $price = 19.95, $taxrate = .05) {
The $price and $taxrate variables whoch were beging sent as hidden inputs in the form, are now hard coded in the function. For example handle_calculator.php renamed as handle_calculator1.php
handle_calculator1.phps | handle_calculator1.php
for check this action tempararaly inseret 1 for form action to calculator.php
Page: First - 1 2 3 4 - Last
|