Location: PHPKode > scripts > Currency Exchange Rates with PHP & XML > sample.php
<?php
/*
	This is a sample file that demonstrates the usage of the currencyExchange class.
	For purposes of this example, make certain that currencyexchange_class.php is 
	saved in the same directory as this file.
*/
//error_reporting(0);
$path=pathinfo($_SERVER['PHP_SELF']);
$path=$_SERVER['DOCUMENT_ROOT'].$path['dirname'];
require_once("$path/currencyexchange_class.php");
$cx=new currencyExchange();
$cx->getData();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="imagetoolbar" content="no">
<meta name="mssmarttagspreventparsing" content="true">
<meta http-equiv="MSThemeCompatible" content="No">
<title>Currency Conversion Example</title>
<style type="text/css">
body{
	background-color: #eee;
	color: #333;
	font: small Verdana, Arial, Helvetica, sans-serif
}
#pricebox{
	background-color: #f7f7f7;
	border:1px solid #000;
	margin: 50px auto;
	padding: 10px;
	width: 300px;
}
#pricebox h1, #pricebox h2, #pricebox p{
	margin: 0;
	padding: 0;
	text-align: center;
}
h1{font-size: 160%;}
h2{font-size: 140%;}
</style>
</head>
<body>
<div id="pricebox">
<h1>Get the New Widget</h1>
<h2>Price $250.00 U.S. dollars</h2>
<p><?php
if ($euro=$cx->Convert("USD","EUR",250)){
	$euro=number_format($euro,2);
	echo "&euro;$euro Euros ";
}
if ($pound=$cx->Convert("USD","GBP",250)){
	$pound=number_format($pound,2);
	echo "<br>\n&pound;$pound British Pounds</p>\n"
		."<p style=\"font-size:smaller;border-top: 1px solid #666;\">Non U.S. pricing based on exchange rates<br>\nin effect as of $cx->Date";
}
?></p></div>
</body>
</html>
Return current item: Currency Exchange Rates with PHP & XML