PHP code example of macromindonline / laravel-money

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

    

macromindonline / laravel-money example snippets


use Cknow\Money\Money;

echo Money::BRL(500); // R$5,00

use Cknow\Money\Money;

Money::BRL(500)->add(Money::BRL(500)); // 10,00
Money::BRL(500)->subtract(Money::BRL(400)); // 1,00
Money::BRL(500)->isZero(); // false
Money::BRL(500)->isPositive(); // true
Money::BRL(500)->isNegative(); // false
Money::BRL(500)->format(); // R$5,00
Money::BRL(500)->formatByDecimal(); // 5.00
Money::parse('R$1,00'); // R$1,00 -> Money::BRL(100)
Money::parseByDecimal('1.00', 'BRL'); // R$1,00 -> Money::BRL(100)

currency('BRL')
money(500, 'BRL')
money_parse('R$5,00')

@currency('BRL')
@money(500, 'BRL')
@money_parse('R$5,00')