sitemap[] = [ 'link' => $link, 'date' => $date, 'change' => $change, 'prior' => $prior, ]; return $this; } public function echoXml(){ header("Content-Type: text/xml"); //header("Expires: Thu, 19 Feb 1998 13:24:18 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Cache-Control: post-check=0,pre-check=0"); header("Cache-Control: max-age=0"); header("Pragma: no-cache"); echo $this; } public function __toString() { $res = ''; foreach ($this->sitemap as $v){ $res .= '' .(($c = $v['link'])? ''.$c.'' :'') .(($c = $v['date'])? ''.(is_numeric($c)?date('Y-m-d',$c):$c).'':'') .(($c = $v['change'])? ''.$c.'' :'') .(($c = $v['prior'])? ''.$c.'' :'') .''; } return ''.$res.''; } }