夜间福利网站,免费动漫av,一级做a爰片久久毛片免费陪,夜夜骑首页,黄色毛片视频,插插插操操操,综合av色

php生成sitemap.xml的實例代碼

時間:2025-09-06 04:12:06 php語言 我要投稿

php生成sitemap.xml的實例代碼

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

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

  php生成sitemap.xml

  例子:

  復制代碼 代碼示例:

  <?PHP

  /**

  * 生成sitemap.xml文件

  */

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

  <urlset

  xmlns="/pic/schemas/sitemap/0.9"

  xmlns:xsi="/pic/2001/XMLSchema-instance"

  xsi:schemaLocation="/pic/schemas/sitemap/0.9

  /pic/schemas/sitemap/0.9/sitemap.xsd">

  ';

  $data_array=array(

  array(

  'loc'=>'/pic/',

  'priority'=>'1.0',

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

  'changefreq'=>'always'

  ),

  array(

  'loc'=>'/pic/',

  '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 提交地址:/pic/webmasters/sitemaps/?hl=zh-CN

  Yahoo 提交地址:/pic/

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

  sitemap.xml的作用,參考:/pic/view/1072062.htm

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

PHP實用的代碼實例08-17

學習php分頁代碼實例12-06

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

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

實用的PHP實例代碼20個02-03

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

實用的PHP語言實例代碼10-22

php自動生成sitemap地圖的代碼11-20

php自動生成sitemap地圖的代碼12-06

  • 相關推薦