PHP code example of xgrz / money
1. Go to this page and download the library: Download xgrz/money library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xgrz / money example snippets
use XGrz\Money\Money;
try {
$money = Money::from(1234.567, precision: 2)
->currency('€', beforeAmount: true)
->decimalSeparator('.')
->thousandsSeparator(',')
->shouldDisplayZero(false);
echo $money->format(); // €1,234.57
} catch (MoneyValidationException $e) {
echo "Error: " . $e->getMessage();
}