Total amount value with tax using php
Date Posted: 22-12-2017
In this Post we will explain Total amount value with tax using php.
Step 1: Create a new file name as index.php and paste the following code.
<?php //The VAT rate. $vat =18; //Divisor (for our math). $vatDivisor = 1 + ($vat / 100); //The gross price, including VAT. $price = 1000; //Determine the price before VAT. $priceBeforeVat = $price / $vatDivisor; //Determine how much of the gross price was VAT. $vatAmount = $price - $priceBeforeVat; //Print out the price before VAT. echo number_format($priceBeforeVat, 2), '<br>'; //Print out how much of the gross price was VAT. echo 'VAT @ ' . $vat . '% - ' . number_format($vatAmount, 2), '<br>'; //Print out the gross price. echo $price; ?>
In the above code vat tax is 18% and price is 1000 and you will get vat tax amount and without amount.