<address id="ousso"></address>
<form id="ousso"><track id="ousso"><big id="ousso"></big></track></form>
  1. php語言

    php生成sitemap.xml的實例代碼

    時間:2025-04-13 17:42:21 php語言 我要投稿
    • 相關推薦

    php生成sitemap.xml的實例代碼

      本文分享一個自己寫的生成sitemap.xml文件的php代碼,感興趣的朋友可以參考下。

      本節內容:

      php生成sitemap.xml

      例子:

      復制代碼 代碼示例:

      <?PHP

      /**

      * 生成sitemap.xml文件

      */

      $content='<?xml version="1.0" encoding="UTF-8"?>

      <urlset

      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9

      http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

      ';

      $data_array=array(

      array(

      'loc'=>'http://www.jbxue.com/',

      'priority'=>'1.0',

      'lastmod'=>'2012-06-03T04:20:32-08:00',

      'changefreq'=>'always'

      ),

      array(

      'loc'=>'http://www.jbxue.com/',

      'priority'=>'0.5',

      'lastmod'=>'2012-06-03T04:20:32-08:00',

      'changefreq'=>'daily'

      )

      );

      foreach($data_array as $data){

      $content.=create_item($data);

      }

      $content.='</urlset>';

      $fp=fopen('sitemap.xml','w+');

      fwrite($fp,$content);

      fclose($fp);

      function create_item($data){

      $item="<url>\n";

      $item.="<loc>".$data['loc']."</loc>\n";

      $item.="<priority>".$data['priority']."</priority>\n";

      $item.="<lastmod>".$data['lastmod']."</lastmod>\n";

      $item.="<changefreq>".$data['changefreq']."</changefreq>\n";

      $item.="</url>\n";

      return $item;

      }

      Sitemap.xml 制作完成后,將xml文件提交到相關搜索引擎以方便搜索引擎更快速的收錄。

      常見的搜索引擎的sitemap的提交地址。

      Google 提交地址:http://www.google.com/webmasters/sitemaps/?hl=zh-CN

      Yahoo 提交地址:http://sitemap.cn.yahoo.com/

      提交后,一般在幾個小時之內,系統就開始下載處理了。

      sitemap.xml的作用,參考:http://baike.baidu.com/view/1072062.htm

    【php生成sitemap.xml的實例代碼】相關文章:

    PHP實用的代碼實例08-12

    學習php分頁代碼實例05-20

    PHP生成SiteMap文件的代碼03-05

    php動態生成JavaScript代碼03-12

    實用的PHP實例代碼20個06-11

    實用的PHP語言實例代碼06-13

    PHP時間戳使用實例代碼03-10

    php自動生成sitemap地圖的代碼07-31

    php自動生成sitemap地圖代碼05-23

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