/*---------------------------------------------------------
Description:
Demonstrates how to represent and display currency
values in PHP using number_format().
---------------------------------------------------------*/
$price = 199.99;
$taxRate = 0.17; // 17%
// Calculate tax and total
$taxAmount = $price * $taxRate;
$total = $price + $taxAmount;
// Output with $ and % signs
echo "Price: $" . number_format($price, 2) . "\n";
echo "Tax Rate: 17%\n";
echo "Tax Amount: $" . number_format($taxAmount, 2) . "\n";
echo "Total: $" . number_format($total, 2) . "\n";
/*
run:
Price: $199.99
Tax Rate: 17%
Tax Amount: $34.00
Total: $233.99
*/