I have the code below: from the getData function im trying to call get_xml within the same class, but I get the error Using $this when not in object context
. I have been programming quite some time, so maybe my brains shut off, but imho this should work right? What am I missing here?
class modDataHelper {
function getData($rid) {
$xml = $this->get_xml('http://www.dataserver.nl/rss/feed.php?id=' . $rid, 60000);
return $xml;
}
function get_xml($url, $max_age) {
$file = 'cache/' . md5($url);
if (file_exists($file)
&& filemtime($file) >= time() - $max_age) {
// the cache file exists and is fresh enough
return simplexml_load_file($file);
}
$xml = file_get_contents($url);
file_put_contents($file, $xml);
return simplexml_load_string($xml);
}
}
In another file I call
$data = modDataHelper::getData(19464);