Question: Write in PHP a weather Web service that takes a ZIP code and the number of days as a query string (e.g., ?zip=79902&days=6) and provides
Write in PHP a weather Web service that takes a ZIP code and the number of days as a query string (e.g., ?zip=79902&days=6) and provides daily forecasts of the specified place for the requested number of days. The output is encoded in JSON e.g., ["sunny", "mostly sunny", "mostly cloudy", "cloudy", "showers", "rain".] If the user supplies no parameters or provides invalid values, use reasonable default values, e.g., one for days.
| Query string | Output |
| ../weather/?zip=79902&days=5 | ["sunny","showers","showers","cloudy","showers"] |
| ../weather/?days=2 | ["cloudy", "mostly sunny"] |
| ../weather/ | ["cloudy"] |
Your script may simulate a weather forecast by selecting a forecast randomly: sunny, mostly sunny, mostly cloudy, cloudy, showers, and rain.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
