PHP Classes

More Info

Recommend this page to a friend!

      Y!Weather  >  All threads  >  More Info  >  (Un) Subscribe thread alerts  
Subject:More Info
Summary:good work
Messages:8
Author:Samer hamouda
Date:2009-04-26 19:04:04
Update:2009-05-13 15:12:00
 

  1. More Info   Reply   Report abuse  
Picture of Samer hamouda Samer hamouda - 2009-04-26 19:04:04
Hi

Nice work

I'm still new in PHP so o wish you can tell me how its work

  2. Re: More Info   Reply   Report abuse  
Picture of Kevin Kevin - 2009-04-27 11:39:31 - In reply to message 1 from Samer hamouda
Hi,

I'll add an example of how to use this class very soon

Thank you
Kevin

  3. Re: More Info   Reply   Report abuse  
Picture of Samer hamouda Samer hamouda - 2009-04-27 19:12:23 - In reply to message 1 from Samer hamouda
Thanks alot for your reply I'll be waiting for the Example you will provid

Sam

  4. Re: More Info   Reply   Report abuse  
Picture of Kevin Kevin - 2009-04-29 16:28:20 - In reply to message 3 from Samer hamouda
Hi,

I didn't take the time to write a nice example but here an example how to play with the class, it's very easy.

<?php
include 'class.weather.php';
$data = new YWeather('UKXX0106', 'c');
$channel = $data->channel();
$item = $data->item();

echo $channel->location->city . <br>;
echo $channel->location->region . <br>;
echo $channel->location->country . <br>;

echo $item->condition->text . <br>;
var_dump($item);
var_dump($channel);
?>

  5. Re: More Info   Reply   Report abuse  
Picture of Kevin Kevin - 2009-04-29 16:29:12 - In reply to message 3 from Samer hamouda
I wrote an example with the interactive shell on my blog

en.pasunclou.com/php/get-the-weathe ...

  6. Re: More Info   Reply   Report abuse  
Picture of Samer hamouda Samer hamouda - 2009-04-29 19:32:27 - In reply to message 4 from Kevin
HI

Thanks for your example i will try it soon

Regards

Samer

  7. Re: More Info   Reply   Report abuse  
Picture of houssem houssem - 2009-05-13 14:51:31 - In reply to message 4 from Kevin
How can i get tomorrow forcast with this class

  8. Re: More Info   Reply   Report abuse  
Picture of Kevin Kevin - 2009-05-13 15:12:00 - In reply to message 7 from houssem
Hi,

To have a better understanding, you need to know how the object is constructed, for this we can use a var_dump

include 'class.weather.php';
$data = new YWeather('UKXX0106', 'c');
$channel = $data->channel();
$item = $data->item();

var_dump($item);

the result:
----
object(stdClass)#9 (2) {
["condition"]=>
object(stdClass)#10 (4) {
["text"]=>
object(SimpleXMLElement)#8 (1) {
[0]=>
string(13) "Light Drizzle"
}
["code"]=>
object(SimpleXMLElement)#11 (1) {
[0]=>
string(1) "9"
....



Now, if I want to get the forecast for tomorow, I use a loop :

include 'class.weather.php';
$data = new YWeather('UKXX0106', 'c');
$channel = $data->channel();
$item = $data->item();
foreach($item->forecast as $key => $value) {
echo $key . " " . $value->text . "\n";
}