PHP code example of chistowick / lettuce

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

    

chistowick / lettuce example snippets




    use Chistowick\Lettuce\ExchangeRatesHandler;

    $erh = new ExchangeRatesHandler();

    // Getting the exchange rate relative to the RUB:
    $erh->usd();
    $erh->eur();

    // Getting a multiplier for converting one currency to another:
    $erh->usdToEur();

    // It will also work
    $erh->USD();
    $erh->USDToEUR();

    // By default, for today:
    echo "USD = {$erh->usd()} RUB";
    echo "EUR = {$erh->eur()} RUB";

    echo "USD to EUR = {$erh->usdToEur()}";

    // or...

    // On the selected date in the YYYY-MM-DD format:
    echo "USD = {$erh->usd('2020-02-29')} RUB";
    echo "EUR = {$erh->eur('2020-02-29')} RUB";

    echo "USD to EUR = {$erh->usdToEur('2020-02-29')}";

    // If you try to get nonexistent data about courses, null is returned.
    $erh->usd('2099-02-29');