PHP code example of wmde / euro

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

    

wmde / euro example snippets


$productPrice = Euro::newFromCents(4200);

$productPrice = Euro::newFromFloat(42.00);

$productPrice = Euro::newFromString('42.00');

$productPrice = Euro::newFromInt(42);

echo $productPrice->getEuroCents();
// 4200 (int) for all above examples

echo $productPrice->getEuroFloat();
// 42.0 (float) for all above examples

echo $productPrice->getEuroString();
// "42.00" (string) for all above examples

Euro::newFromCents(4200)->equals(Euro::newFromInt(42));
// true

Euro::newFromCents(4201)->equals(Euro::newFromInt(42));
// false