Function __global->currency_convert
Definitions
sources/currency.php
- Perform a currency conversion.Not cache safe.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
Parameters
| Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
|---|---|---|---|---|---|---|---|
| $amount | mixed | No | No | required parameter | N/A | N/A | The starting amount (integer or float) |
| $from_currency | ?ID_TEXT | No | No | Null | N/A | N/A | The start currency code (null: site currency) |
| $to_currency | ?ID_TEXT | No | No | Null | N/A | N/A | The end currency code (null: something appropriate for the user) |
| $display_method | integer | No | No | 0 | N/A | N/A | A CURRENCY_DISPLAY_* constant |
| $force_via | ?ID_TEXT | No | No | Null | conv_api | N/A | Force conversion via this API (null: no restriction) |
Returns
- The new amount with the specified display method (CURRENCY_DISPLAY_RAW is a float, otherwise a string) (null: error)
- Type: ?mixed
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* Perform a currency conversion.Not cache safe.
*
* @param mixed $amount The starting amount (integer or float)
* @param ?ID_TEXT $from_currency The start currency code (null: site currency)
* @param ?ID_TEXT $to_currency The end currency code (null: something appropriate for the user)
* @param integer $display_method A CURRENCY_DISPLAY_* constant
* @param ?ID_TEXT $force_via Force conversion via this API (null: no restriction)
* @set conv_api
* @return ?mixed The new amount with the specified display method (CURRENCY_DISPLAY_RAW is a float, otherwise a string) (null: error)
*/
function currency_convert($amount, ?string $from_currency = null, ?string $to_currency = null, int $display_method = 0, ?string $force_via = null)
* Perform a currency conversion.Not cache safe.
*
* @param mixed $amount The starting amount (integer or float)
* @param ?ID_TEXT $from_currency The start currency code (null: site currency)
* @param ?ID_TEXT $to_currency The end currency code (null: something appropriate for the user)
* @param integer $display_method A CURRENCY_DISPLAY_* constant
* @param ?ID_TEXT $force_via Force conversion via this API (null: no restriction)
* @set conv_api
* @return ?mixed The new amount with the specified display method (CURRENCY_DISPLAY_RAW is a float, otherwise a string) (null: error)
*/
function currency_convert($amount, ?string $from_currency = null, ?string $to_currency = null, int $display_method = 0, ?string $force_via = null)
