PHP数组的急问题
<code><?php
class weather
{
var$weather=array("","","","","");
function weather()
{
$fcont=@file_get_contents("http://www.tq121.com.cn/forecast/cf.php");
$data=explode("<font color=\"#FF0000\">", $fcont);
$fdate=substr($data,2,18);
$city=explode("461,292,498,308", $fcont);
$fcast=$city;
$fcastarr=explode("<br>", $fcast);
$wea=chop(substr($fcastarr,-5,5));
$wea=chop(substr(trim($fcastarr),5));
$wea=chop(substr(trim($fcastarr),5));
$wea=chop(substr(trim($fcastarr),5));
$wea=chop(substr(trim($fcastarr),5));
$this->$weather=$wea;
$this->$weather=$wea;
}
}
?>
<?PHP
$kkk=new weather;
print $kkk->$weather;
</code>
$weather应该是"上海"
$weather应该是天气情况.
为什么输入的情况却是.$weather和weather相同呢. 跟踪$wea=chop(substr(trim($fcastarr),5))的值
从http://www.tq121.com.cn/forecast/cf.php获得的天气预报是否保证了数据的一一对应 :idea: 在$wea[]中的值是一一对应的.可是到了$weather中的时候就不对了.
$this->$weather=$wea;
$this->$weather=$wea;
好像不是这么用吧?
很久不用了………
$this->$weather=$wea;
$this->$weather=$wea;
好像不是这么用吧?
很久不用了………
那应该怎么用的啊。???? echo $kkk->weather;
页:
[1]