Forum Moderators: coopster
Thank you for that jatar but i have tried it and the comment i get get is unexpected T variable.
Vehicle ($car) is from another function. When a user clicks from a drop down menu, it shows a message and a price. So i wanted to use the information from another function to another function in stead of putting the figures in for about 6 items
instead of putting $price = 16.00
i wanted to put $price = vehicle($car) which stems from another function
switch ($cars) {
case "white":
$pricestr = "5.00.\n" ;
break;
case "brown":
$pricestr = "6.00\n" ;
break;
case "green":
$pricestr = "7.00\n" ;
break;
case "blue":
$pricestr = " 8.00\n" ;
break;
case "orange":
$pricestr = " 7.50\n" ;
break;
}
return $pricestr;
}
?>
<?php
function add_tax ($amount) {
$total = $amount * 5.09;
return $total;
}
$price = vehicle($cars);
$taxprice = add_tax($price);
?>
$pricestr = "5.00.\n" ;
that means you have a string in there and then you do
$total = $amount * 5.09;
in the next function, that just won't work. You need to have ints in the first function. something like this
function vehicle($cars) {
switch ($cars) {
case "white":
$pricestr = "5.00" ;
break;
case "brown":
$pricestr = "6.00" ;
break;
case "green":
$pricestr = "7.00" ;
break;
case "blue":
$pricestr = " 8.00" ;
break;
case "orange":
$pricestr = " 7.50" ;
break;
}
return $pricestr;
}
function add_tax ($amount) {
$total = $amount * 5.09;
return $total;
}
$cars = 'brown';
$price = vehicle($cars);
$taxprice = add_tax($price);
echo '<p>price before tax ' . $price;
echo "<p>price after tax " . $taxprice;
?>