PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Helmut Daschnigrum   Currency Exchange   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Currency Exchange
Obtains exchange rates for various currencies
Author: By
Last change:
Date: 17 years ago
Size: 842 bytes


Class file image Download

// CurrencyExchange class usage example
$exchange = new CurrencyExchange();
if (
$exchange->retrieve()) {

// Display the current Canadian exchange rate information

// Display all exchange rates returned by the CurrencyExchange class
foreach ($exchange->rates as $currency=>$rate) {
"Currency: $currency<br>".
"Exchange rate: ". $rate["rate"]."<br>".
"Country: ". $rate["unit"]."<br>".
"Units: ". $rate["unit"]."<br>".
"Date retrieved: ". $rate["date"]."<br><br>";

// Display information about the source of the exchange rate information
// (eg: if it was retrieved from the Federal Reserve Bank of NY, the
// Bank of Canada, etc.)
// ------------------------------------------------------------------------