PHP code example of elliotwms / abacus

1. Go to this page and download the library: Download elliotwms/abacus 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/ */

    

elliotwms / abacus example snippets


$abacus = new Abacus(1250.00);          // Create a new Abacus object. Defaults to USD
echo $abacus;                           // "1250.00"
echo $abacus->format();                 // "$1,250.00"
echo $abacus->value                     // 1250

$abacus->toCurrency("GBP");             // Convert USD to GBP

$abacus->add(20);                       // Addition
$abacus->add(10, "GBP");                // Addition of a value in another currency
$abacus->add(new Abacus(5, "GBP");      // Adding another Abacus object
                                        
$abacus->sub(20);                       // Subtraction
$abacus->sub(10, "GBP");                // Subtraction of a value in another currency
$abacus->sub(new Abacus(5, "GBP");      // Subtract another Abacus object

Currency::update();

Currency::update('my_api_key');
bash
export ABACUS_OPEN_EXCHANGE_KEY=your_abacus_api_key
echo $ABACUS_OPEN_EXCHANGE_KEY
bash
 php bin/abacus