|
<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[1],2,1;
$city=explode("461,292,498,308", $fcont);
$fcast=$city[1];
$fcastarr=explode("<br>", $fcast);
$wea[0]=chop(substr($fcastarr[0],-5,5));
$wea[1]=chop(substr(trim($fcastarr[1]),5));
$wea[2]=chop(substr(trim($fcastarr[2]),5));
$wea[3]=chop(substr(trim($fcastarr[3]),5));
$wea[4]=chop(substr(trim($fcastarr[4]),5));
$this->$weather[0]=$wea[0];
$this->$weather[1]=$wea[1];
}
}
?>
<?PHP
$kkk=new weather;
print $kkk->$weather[0];
</code>
$weather[0]应该是"上海"
$weather[1]应该是天气情况.
为什么输入的情况却是.$weather[0]和weather[1]相同呢. |
|