Execute a method less times possible - PHP
Posted
by serhio
on Stack Overflow
See other posts from Stack Overflow
or by serhio
Published on 2010-03-07T10:29:32Z
Indexed on
2010/03/08
8:51 UTC
Read the original article
Hit count: 208
I have a site in multiple languages. I have a method that returns me the today currencies in a array. I display that currencies in a table then.
// --- en/index.php
<?php
include_once "../exchangeRates.php";
$currencies = ReadExchangeRates();
// --- fr/index.php
<?php
include_once "../exchangeRates.php";
$currencies = ReadExchangeRates();
...
// somewhere in the page
<td><?php echo $currencies["eur"]["today"]; ?></td>
So, every time I load, en/
or fr/
or other language, I request the exchange rates from a external site.
Can I optimize this behavior (reading once per day or session)?
maybe to store a global variable and check the update date?
© Stack Overflow or respective owner