PHP code example of wandersonwhcr / plates-romans

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

    

wandersonwhcr / plates-romans example snippets


use League\Plates\Engine;
use League\Plates\Romans\Extension\Romans as RomansExtension;

$engine = new Engine();

$engine->loadExtension(new RomansExtension());

use League\Plates\Romans\Extension\Exception as ExtensionException;

try {
    $this->arabicToRoman('-1');
} catch (ExtensionException $e) {
    // Invalid Integer: -1
}

try {
    $this->romanToArabic('Z');
} catch (ExtensionException $e) {
    // Invalid Token: Z
}

// Outputs MCMXCIX
Arabic 1999 can be represented as  echo $this->arabicToRoman('1999') 

// Outputs 2021
Roman MMXXI can be represented as  echo $this->romanToArabic('MMXXI')