Get Weather - Step 10 - The bottom line...


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. //back to our "black roots"...
  2. class WeatherService{
  3.  
  4. private $cache;
  5.  
  6. public function WeatherService(){
  7. //some initialization...
  8. $cache = new DBCache(); //******** THE ONLY THING CHANGED !!!!!!!!!!!!!!!!!
  9. }
  10.  
  11. public function getWeatherInfo($city, $method){
  12.  
  13. if ($cache->get($city))
  14. return $cache->get($city);
  15.  
  16. $res = shell_exec("./getWdr.sh {$city}");
  17.  
  18. if ($methos=="CL")
  19. return convertFrToC($res);
  20.  
  21. return $res;
  22. }
  23.  
  24. private function convertFrToC($val){
  25. return (($val+40)*5/9)-40;
  26. }
  27.  
  28. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.