im trying to cache xml to a file... see code below:
function getDomains($url)
{
$cache_time = 300; //time in seconds
if(!file_exists('domains.xml'))
{
$xml = simplexml_load_string($url); //parser error : Start tag expected, '<' not found in
file_put_contents('domains.xml',$xml);
$xml = simplexml_load_file('domains.xml');
return $xml;
}
elseif(file_exists('domains.xml'))
{
$modified = @filemtime('domains.xml');
$now = strtotime("now");
$difference = $now - $modified;
if ($difference >= $cache_time)
{
$xml = simplexml_load_string($url);
file_put_contents('domains.xml',$xml);
$xml = simplexml_load_file('domains.xml');
return $xml;
}
else
{
$xml = simplexml_load_file('domains.xml');
return $xml;
}
}
}
am i fudging this up somehow?