1. Go to this page and download the library: Download breeze_converter/currency 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/ */
breeze_converter / currency example snippets
use converter\Converter;
try {
$converter = new Converter([
'basecurrency' => 'USD', // Optional: default is 'USD'
'defaultamount' => 100, // Optional: default is 1
'cookieexpiry' => 300 // Optional: caching duration in seconds
]);
$result = $converter
->from('USD') // Set base currency
->to(['EUR', 'GBP', 'CAD']) // Set target currencies
->amount(100) // Set amount to convert
->run('json'); // Get result in JSON format
echo $result; // Output converted values as JSON
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
Array
(
[status] => error
[message] => "Currency conversion rate for INVALID not available."
)
$converter->baseCurrency('CAD'); // Sets the base currency to CAD
$converter->defaultAmount(100); // Sets the amount to 100 units of the default currency
$converter->expiry(300); // Set cache expiry time to 300 seconds (5 minutes)
$converter = new Converter();
// Set base currency to CAD, default amount to 100, and cache expiry to 5 minutes
$converter->baseCurrency('CAD')
->defaultAmount(100)
->expiry(300);
// Convert from CAD to NGN, GBP, and USD, and get the result in JSON format
$result = $converter->to(['NGN', 'GBP', 'USD'])->run('json');
echo $result;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.