PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Marcel Kohls   PHP Open Weathermap   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: index file, demo
Class: PHP Open Weathermap
Get the weather for a given location
Author: By
Last change: showing new classes proprerties, again
Date: 8 years ago
Size: 786 bytes
 

Contents

Class file image Download
<?php
   
require_once('Weather.class.php');
   
   
$weather = new Weather();
   
   
$weather->latitude = "-26.984500";
   
$weather->longitude = "-48.631668";
   
$weather->unit = "C"; // units can be: "F" for Fahrenheit, "C" for Celsius, "K" for Kelvin
   
$weather->apiKey = "api-code-here";
   
   
    if (
$weather->loadWeather() == true){
        echo
'weather now is: <br />';
        echo
$weather->general.'<br />';
        echo
'('.$weather->detailed.')<br />';
        echo
'<img src="http://openweathermap.org/img/w/'.$weather->icon.'.png"><br />';
        echo
$weather->temperature.' '.$weather->unit.' <br /> ';
        echo
'min.:'.$weather->temp_min.' / max.:'.$weather->temp_min.'<br />';
        echo
'pressure: '.$weather->pressure.' hpa<br /> ';
        echo
'humidity: '.$weather->humidity.'% <br /> ';
       
//hpa
   
}
?>