Notice: Trying to get property 'title' of non-object in /home/users/1/buturi/web/php/weather.php on line 7

Notice: Trying to get property 'description' of non-object in /home/users/1/buturi/web/php/weather.php on line 9

Notice: Trying to get property 'text' of non-object in /home/users/1/buturi/web/php/weather.php on line 9

Notice: Trying to get property 'forecasts' of non-object in /home/users/1/buturi/web/php/weather.php on line 12

Notice: Trying to access array offset on value of type null in /home/users/1/buturi/web/php/weather.php on line 12

Notice: Trying to get property 'date' of non-object in /home/users/1/buturi/web/php/weather.php on line 12

Notice: Trying to get property 'forecasts' of non-object in /home/users/1/buturi/web/php/weather.php on line 13

Notice: Trying to access array offset on value of type null in /home/users/1/buturi/web/php/weather.php on line 13

Notice: Trying to get property 'telop' of non-object in /home/users/1/buturi/web/php/weather.php on line 13

Notice: Trying to get property 'forecasts' of non-object in /home/users/1/buturi/web/php/weather.php on line 14

Notice: Trying to access array offset on value of type null in /home/users/1/buturi/web/php/weather.php on line 14

Notice: Trying to get property 'image' of non-object in /home/users/1/buturi/web/php/weather.php on line 14

Notice: Trying to get property 'url' of non-object in /home/users/1/buturi/web/php/weather.php on line 14

Notice: Trying to get property 'forecasts' of non-object in /home/users/1/buturi/web/php/weather.php on line 17

Notice: Trying to access array offset on value of type null in /home/users/1/buturi/web/php/weather.php on line 17

Notice: Trying to get property 'date' of non-object in /home/users/1/buturi/web/php/weather.php on line 17

Notice: Trying to get property 'forecasts' of non-object in /home/users/1/buturi/web/php/weather.php on line 18

Notice: Trying to access array offset on value of type null in /home/users/1/buturi/web/php/weather.php on line 18

Notice: Trying to get property 'telop' of non-object in /home/users/1/buturi/web/php/weather.php on line 18

Notice: Trying to get property 'forecasts' of non-object in /home/users/1/buturi/web/php/weather.php on line 19

Notice: Trying to access array offset on value of type null in /home/users/1/buturi/web/php/weather.php on line 19

Notice: Trying to get property 'image' of non-object in /home/users/1/buturi/web/php/weather.php on line 19

Notice: Trying to get property 'url' of non-object in /home/users/1/buturi/web/php/weather.php on line 19

Notice: Trying to get property 'forecasts' of non-object in /home/users/1/buturi/web/php/weather.php on line 20

Notice: Trying to access array offset on value of type null in /home/users/1/buturi/web/php/weather.php on line 20

Notice: Trying to get property 'temperature' of non-object in /home/users/1/buturi/web/php/weather.php on line 20

Notice: Trying to get property 'min' of non-object in /home/users/1/buturi/web/php/weather.php on line 20

Notice: Trying to get property 'celsius' of non-object in /home/users/1/buturi/web/php/weather.php on line 20

Notice: Trying to get property 'forecasts' of non-object in /home/users/1/buturi/web/php/weather.php on line 21

Notice: Trying to access array offset on value of type null in /home/users/1/buturi/web/php/weather.php on line 21

Notice: Trying to get property 'temperature' of non-object in /home/users/1/buturi/web/php/weather.php on line 21

Notice: Trying to get property 'max' of non-object in /home/users/1/buturi/web/php/weather.php on line 21

Notice: Trying to get property 'celsius' of non-object in /home/users/1/buturi/web/php/weather.php on line 21
天気予報

ソースコード

<?php
$tmp_url 
"http://weather.livedoor.com/forecast/webservice/json/v1?city=340010";
$json file_get_contents$tmp_url ) or die("Failed to get json");
$json mb_convert_encoding$json'UTF8''ASCII,JIS,UTF-8,EUC-JP,SJIS-WIN' );
$obj json_decode($json);

$title $obj->title;

$description =  $obj->description->text;

//today
$today $obj->forecasts[0]->date;
$today_telop $obj->forecasts[0]->telop;
$today_img_url $obj->forecasts[0]->image->url;

//tommorow
$tomorrow $obj->forecasts[1]->date;
$tomorrow_telop $obj->forecasts[1]->telop;
$tomorrow_img_url $obj->forecasts[1]->image->url;
$tomorrow_minT $obj->forecasts[1]->temperature->min->celsius;
$tomorrow_maxT $obj->forecasts[1]->temperature->max->celsius;

?>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>天気予報</title>
<style>
body{ line-height: 200%;}
div.code{ border: 1px solid gray; border-radius: 3px; padding: 1em; }
</style>
</head>
<body>
<h1><?php echo $title;?></h1>
<p><?php  echo $description?></p>
<ul>
<li> 今日の日付: <?php echo $today;?>
<li> 今日の天気: <?php echo $today_telop?>
<li> 今日の天気画像: <?php echo "<img src='".$today_img_url."'>"?>

<li> 明日の日付: <?php echo $tomorrow;?>
<li> 明日の天気: <?php echo $tomorrow_telop ?>
<li> 明日の天気画像: <?php echo "<img src='".$tomorrow_img_url."'>"?>
<li> 明日の最高温度: <?php echo $tomorrow_maxT?>
<li> 明日の最低温度: <?php echo $tomorrow_minT?>
</ul>


<h3>ソースコード</h3>
<div class="code">
<?php show_source("weather.php");?>
</div>

</body>
</html>