Hello,
This line gives an error; $this->page->loadXML($this->getXML());
Where’s the error?
class Doviz {
private $page, $currencies;
public function __construct(){
$this->page = new DOMDocument;
$this->page->loadXML($this->getXML());
$this->currencies = array();
$this->initCurrencies();
return $this;
}
private function getXML(){
if (isset($_SERVER['HTTPS']) &&
($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$xmlURL = 'https://www.tcmb.gov.tr/kurlar/today.xml';
}
else {
$xmlURL = 'http://www.tcmb.gov.tr/kurlar/today.xml';
}
if(function_exists('curl_version')){
$ch = curl_init();
curl_setopt_array($ch,
array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $xmlURL
)
);
$xmlPage = curl_exec($ch);
curl_close($ch);
}
else{
$xmlPage = file_get_contents($xmlURL);
}
return $xmlPage;
}