av手机免费在线观看,国产女人在线视频,国产xxxx免费,捆绑调教一二三区,97影院最新理论片,色之久久综合,国产精品日韩欧美一区二区三区

php語言

php生成sitemap.xml的實(shí)例代碼

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

php生成sitemap.xml的實(shí)例代碼

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

  本節(jié)內(nèi)容:

  php生成sitemap.xml

  例子:

  復(fù)制代碼 代碼示例:

  <?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文件提交到相關(guān)搜索引擎以方便搜索引擎更快速的收錄。

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

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

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

  提交后,一般在幾個小時之內(nèi),系統(tǒng)就開始下載處理了。

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

【php生成sitemap.xml的實(shí)例代碼】相關(guān)文章:

PHP實(shí)用的代碼實(shí)例08-12

學(xué)習(xí)php分頁代碼實(shí)例05-20

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

php動態(tài)生成JavaScript代碼03-12

實(shí)用的PHP實(shí)例代碼20個06-11

實(shí)用的PHP語言實(shí)例代碼06-13

PHP時間戳使用實(shí)例代碼03-10

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

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