currencyexchange_class.php Read Me File

Copyright (c) 2005, Gary White. See the file gpl.txt for details.
Please report any bugs at

Important: The currency exchange rates are obtained from the European Central Band and are based on the regular daily concertation procedure between central banks within and outside the European System of Central Banks, which normally takes place at 2.15 p.m. ECB time (CET). The rates are believed to be accurate, however, the developer of this class assumes no responsibility for the accuracy of those rates. For more information on how the rates are developed, see Euro foreign exchange reference rates at the European Central Bank web site.

Files Included in this Archive
File Name Description
currencyexchange_class.php The currencyExchange class file
gpl.txt The General Public License
readme.html This file
sample.php A sample of how to use the class


Extract the files from this archive. The only file necessary for functionality is the currencyexchange_class.php file.


None is required.


See the sample.php file included in the .zip file.

Object Model

currencyExchange Object
Name Type Read Only Description
Date String Read only The date the conversion rates were posted by ECB in YYYY-MM-DD format.
Error String Read only Description of last error encountered.
Source String Read only Will be either "Local" or "Remote" depending on whether the data was obtained from the cached local copy or the remote XML file.
Supplier String Read only If data is successfully obtained, this should be European Central Bank.
localFile String Read/write The name and optionally a site root relative path to where the local cached copy of the remote XML file is to be stored.
url String Read only The URL to the remote XML file at the European Central Bank web site.

Note that some properties are marked as read only. PHP does not have the capacity to actually make properties read only. The read only notation above is informational only. Attempting to assign a value to one of the read only properties will generate no error, however, after assigning a value to one of those properties will lead to unpredictable results.

Name Parameters Return type Description
getData None Integer Gets the data from the cached local file if available, or from the remote ECB file if newer. Returns the number of exchange rates in the XML file.
Convert $from, $to, $amount Float Converts $amount from $from currency to $to currency and returns the result. The $from and $to parameters are the three letter identiers that represent the desired currencies.
setBaseCurrency $currency Boolean The original rates in the XML file are based on conversion of other currencies to one Euro. You can change this to base the conversion on one unit of any of the other supported currencies. Note that this would only be useful if you are outputting a table of currency conversion rates.

The most recent version of the currencyExchange class is available at