超碰免费人人操|国产视频二区久久艹人人操|欧美激情第一页在线|久热最新无码中文视频|91精品国际成人|亚洲成人精品在线视频青青草|久草免费高清完整在线观看|你懂的AV在线日本黄网页|国产黄色AV日韩女同网|欧美成人色区导航片av

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

時(shí)間:2025-09-06 04:12:06 php語(yǔ)言

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

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

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

  php生成sitemap.xml

  例子:

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

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

  常見(jiàn)的搜索引擎的sitemap的提交地址。

  Google 提交地址:/pic/webmasters/sitemaps/?hl=zh-CN

  Yahoo 提交地址:/pic/

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

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

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

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

學(xué)習(xí)php分頁(yè)代碼實(shí)例12-06

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

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

實(shí)用的PHP實(shí)例代碼20個(gè)02-03

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

實(shí)用的PHP語(yǔ)言實(shí)例代碼10-22

php自動(dòng)生成sitemap地圖的代碼11-20

php自動(dòng)生成sitemap地圖的代碼12-06