I'm trying to add a mark up percentage to the $cents per Mile, for some reason it ignores it. How can I create a var that I can enter a whole number for percentage and have it add it to the cost?
<?php
$PriceofgallonGas = 2.59 ;
$precent = 50 ;
?>
<?php
function installVanFuel() {
global $PriceofgallonGas,$precent;
$TankMiles = 254;
$SizeofTankinGallons = 31;
$mpg = $TankMiles / $SizeofTankinGallons;
$markup = (1 + $percent/100);
$centsPerMile = $PriceofgallonGas/$mpg;
echo round($centsPerMile*$markup, 2);
}
?>
You have a spelling mistake, please check.
At $markup = (1 + $percent/100);
you miss spelled the variable $percent
.
$PriceofgallonGas = 2.59 ;
$precent = 50 ;
function installVanFuel() {
global $PriceofgallonGas, $precent;
$TankMiles = 254;
$SizeofTankinGallons = 31;
$mpg = $TankMiles / $SizeofTankinGallons;
$markup = (1 + $precent/100);
$centsPerMile = $PriceofgallonGas/$mpg;
echo round($centsPerMile*$markup, 2)." Cents x ".$precent."%"; //0.47 Cents x 50%
}
installVanFuel();