urlToPath($url); if (!file_exists($path) || filectime($path) + $this->seconds < time()) { echo "Weather data is NOT cached!\n"; return false; } echo "Weather data is cached!\n"; return true; } /** * @inheritdoc */ public function getCached($url) { return file_get_contents($this->urlToPath($url)); } /** * @inheritdoc */ public function setCached($url, $content) { file_put_contents($this->urlToPath($url), $content); } } // Language of data (try your own language here!): $lang = 'de'; // Units (can be 'metric' or 'imperial' [default]): $units = 'metric'; // Example 1: Use your own cache implementation. Cache for 10 seconds only in this example. $owm = new OpenWeatherMap(null, new ExampleCache(), 10); $weather = $owm->getWeather('Berlin', $units, $lang); echo "EXAMPLE 1