I was trying to make weather based PHP script to show weather related data.But,I’m facing this error message
Fatal error: Call to undefined method weather::get()
Would you please let me know how can i fix this or what was my problem??You can check out my code here:
<?php
include 'weather.php';
$t_weather = new weather();
$info = $t_weather->get('New York');
echo "Current temperature in {$info[0]['location']} is: {$info[0]['current_condition']['temperature']['f']} °F";
?>
This is weather.php:
<?php
class weather {
// API data
private $API_NAME = 'weather';
private $API_KEY = '***********';
}
?>
Thanks in advance.
Well your
weatherclass doesn’t have a method named get. Are you using someone else’s class to do this? You should have something like: