- How to calculate VAT against a price with PHP.
- PHP function to calculate VAT.
- Calculating tax against price with PHP.
- Calculate total price including VAT.
This function calculates the vat against the price and adds it into the price. Function accepts 2 parameters. First parameter is VAT rate and the second parameter is the price.
Function
function vat($price,$vat=17.5) {
$price_with_vat=0;
$price_with_vat = $price + ($vat*($price/100));
$price_with_vat = round($price_with_vat, 2);
return $price_with_vat;
}
Calling The Function
echo vat(150);
Output
176.25

Leave A comment
Email address is optional and will not be published. Only add email address if you want a reply from blog author.
Please fill required fields marked with *