<address id="ousso"></address>
<form id="ousso"><track id="ousso"><big id="ousso"></big></track></form>
  1. php如何獲取指定地區天氣

    時間:2025-10-21 17:26:54 php語言

    php如何獲取指定地區天氣

      導語:php如何獲取指定地區天氣呢?下面是小編給大家推薦的代碼實現,大家可以參考閱讀,更多詳情請關注應屆畢業生考試網。

      PHP 獲取指定地區的天氣

      在開發網站的時候用到天氣查詢,由于是基于Wordpress的 所以有很多限制,先建一個【weather.PHP】的文件,然后看代碼:

      <?php

      /pic/p>

      $url = '/pic/data/';

      $id = '101181101'; /pic/p>

      $data = file_get_contents($url . $id .'.html');

      $obj=json_decode($data);

      echo $obj->weatherinfo->city.':'.$obj->weatherinfo->weather1.' '.$obj->weatherinfo->temp1;

      而對于:

      $obj=json_decode($data);

      它是把獲取的json數據轉化為一個對象,方便調用;

      那么最后一句:

      echo $obj->weatherinfo->city.':'.$obj->weatherinfo->weather1.' '.$obj->weatherinfo->temp1;

      就是獲取指定的數據并按照一定格式輸出,

      $obj->weatherinfo->city /pic/p>

      $obj->weatherinfo->weather1 /pic/p>

      $obj->weatherinfo->temp1 /pic/p>

      最后 在需要顯示的地方

      <?php include 'weather.php' ?>

      即可。

    【php如何獲取指定地區天氣】相關文章:

    PHP如何獲取表單10-26

    PHP如何獲取系統信息02-02

    如何利用PHP語言獲取連接信息11-04

    php通過Chianz.com獲取IP地址與地區的方法11-18

    如何實現PHP獲取表單數據與HTML嵌入PHP腳本01-16

    如何使用php獲取excel文件數據08-26

    PHP獲取星期的方法08-08

    php怎么獲取input的id08-25

    php創建cookie獲取方法02-10

    <address id="ousso"></address>
    <form id="ousso"><track id="ousso"><big id="ousso"></big></track></form>
    1. 日日做夜狠狠爱欧美黑人