2007 yılında yazdığım yazıları incelerken hava durumu çeken bir betikle karşılaştım.
yeni şehir eklemek için http://weather.msn.com adresinden arama yapıyoruz. Ekleyeceğimiz şehir adresinin adresinin TUXX ile başlayan kısmını alıyoruz.
http://weather.msn.com/local.aspx?wealocations=wc:TUXX0014
deneme.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <?php header("Content-Type: text/html; charset=utf-8"); include "weather.class.php"; include "cache.class.php"; $weather = new Weather(); $array = $weather->GetWeather($_REQUEST['id']); $array2 = $weather->GetWeather($_REQUEST['id'], true); echo 'Su anda [ $weather->GetWeather($_REQUEST[\'id\']) ]'; print_r($array); echo '5 gunluk [ $weather->GetWeather($_REQUEST[\'id\', true]) ]'; print_r($array2); ?> |
http://127.0.0.1/deneme.php?id=TUXX0014 adresini çağırdığımızda ekran çıktısı.
Su anda [ $weather->GetWeather($_REQUEST['id']) ]
Array
(
[0] => Array
(
[degree] => 21°C
[humidity] => 73
[winds] => 2 km/sa
[feels] => 21
[time] => 05:50
[day] => 24.06.2009
[desc] => Açık
[image] => 32.gif
[place] => İstanbul
))
5 gunluk [ $weather->GetWeather($_REQUEST['id', true]) ]
Array
(
[0] => Array
(
[degree] => 21°C
[humidity] => 73
[winds] => 2 km/sa
[feels] => 21
[time] => 05:50
[day] => 24.06.2009
[desc] => Açık
[image] => 32.gif
[place] => İstanbul
)[1] => Array
(
[high] => 32°C
[low] => 23°C
[image] => 34.gif
[chance] => 45
[desc] => Ilık
)[2] => Array
(
[high] => 29°C
[low] => 22°C
[image] => 34.gif
[chance] => 10
[desc] => Ilık
)[3] => Array
(
[high] => 25°C
[low] => 20°C
[image] => 11.gif
[chance] => 85
[desc] => ÖÖ Yağmurlu
)[4] => Array
(
[high] => 28°C
[low] => 22°C
[image] => 30.gif
[chance] => 65
[desc] => Parçalı Bulutlu
)[5] => Array
(
[high] => 29°C
[low] => 23°C
[image] => 28.gif
[chance] => 50
[desc] => ÖS Bulutlu
))
ayrıca sistemin ajax, cache mekanızması ve hava durum ikonlarıda vardır.
dosya : msn weather hava durumu
bir tanede resimli örnek yapalım
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | <?php header("Content-Type: text/html; charset=utf-8"); include "weather.class.php"; include "cache.class.php"; $weather = new Weather(); $array = $weather->GetWeather($_REQUEST['id']); $array2 = $weather->GetWeather($_REQUEST['id'], true); echo '<div><strong>gunluk</strong></div>'; echo '<div>'.$array[0][place].' - '.$array[0][day].' tarihli hava durumu</div>'; echo '<div>sicaklik : '.$array[0][degree].'</div>'; echo '<div>nem : '.$array[0][humidity].'</div>'; echo '<div>ruzgar : '.$array[0][winds].'</div>'; echo '<div>hissedilen : '.$array[0][feels].'</div>'; echo '<div>aciklama : '.$array[0][desc].'</div>'; echo '<div>resim : <img src="images/'.$array[0][image].'"></div>'; echo '<div><strong>5 gunluk</strong></div>'; $i = 0; foreach($array2 as $hava) { if($i == 0) { echo '<div>'.$hava[place].' - '.$hava[day].' tarihli hava durumu</div>'; echo '<div>sicaklik : '.$hava[degree].'</div>'; echo '<div>nem : '.$hava[humidity].'</div>'; echo '<div>ruzgar : '.$hava[winds].'</div>'; echo '<div>hissedilen : '.$hava[feels].'</div>'; echo '<div>aciklama : '.$hava[desc].'</div>'; echo '<div>resim : <img src="images/'.$hava[image].'"></div>'; } else { $tarihayir = explode('.',$array2[0][day]); $gun = $tarihayir[0] + $i; $time = date("d.m.Y", mktime(0, 0, 0, $tarihayir[1], $gun, $tarihayir[2])); echo '<div>'.$array2[0][place].' - '.$time.' tarihli hava durumu</div>'; echo '<div>en yuksek : '.$hava[high].'</div>'; echo '<div>en alcak : '.$hava[low].'</div>'; echo '<div>degisim : % '.$hava[chance].'</div>'; echo '<div>aciklama : '.$hava[desc].'</div>'; echo '<div>resim : <img src="images/'.$hava[image].'"></div>'; } $i = $i + 1; } ?> |
iyi kullanımlar.
benzer konu bulunamadı














design patterns