[eluser]Unknown[/eluser]
sorry for my bad(very bad) english
i have controller
Code:
<?php
class Main extends Controller {
function Main()
{
parent::Controller();
}
function index() {
$this->load->library('weather');
echo $this->weather->getWeather(1310);
}
}
?>
and simple library
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Weather {
function Weather() {
$this->CI =& get_instance();
}
public function getWeather($city) {
$xmlstr = @join('',file('http://weather.co.ua/xml/feed.xml?version=1.1&city;='.intval($city).'&dayf=5'));
$xml = new SimpleXMLElement($xmlstr);
for($i=0;$i<24;$i++) {
$xmlpath = $xml->forecast->day[$i];
$cloud = $xmlpath->cloud;
$pict = $xmlpath->pict;
$ppcp = $xmlpath->ppcp;
$tmin = $xmlpath->t->min;
$tmax = $xmlpath->t->max;
$pmin = $xmlpath->p->min;
$pmax = $xmlpath->p->max;
$wmin = $xmlpath->wind->min;
$wmax = $xmlpath->wind->max;
$wrumb = $xmlpath->wind->rumb;
$hmin = $xmlpath->hmid->min;
$hmax = $xmlpath->hmid->max;
$wpi = $xmlpath->wpi;
$city = intval($city);
}
}
}
?>
whis work! but on every line whith "$xmlpath->..." i have per line for two similar errors
Quote:A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: libraries/Weather.php
Line Number: 22 <- every line whith "$xmlpath->..."
what is wrong?