实现的效果如下:

thinkPHP生成网站地图sitemap.html的实现方法:
protected function articlehtml(){
$list = db('article')
->alias('a')
->join('column b','b.c_id=a.a_columnid')
->order('a_id asc')->select();
$sitemap='<!doctype html><head><meta charset="utf-8"><title>文章列表网站地图</title></head><body>';
foreach($list as $k=>$v){
$path=$v['c_path'];
$pid=$v['a_id'].'.html';
$sitemap.="<a href='http://tp6.wyzdjg.top/$path/$pid'>".$v['a_title']. "</a> # http://tp6.wyzdjg.top/".$v['c_path'].'/'.$v['a_id'].'.'.html ."<br/>";
}
$sitemap.='</body></html>';
// if (file_exists(sitemap.html)){
// unlink(sitemap.html);
// }else {
file_put_contents('sitemap.html', $sitemap, FILE_APPEND);
// }
}
上面的域名改成自己的,设成一个变量也可以,上面是个简单的例子是写成固定的

哔哩哔叽


















