public static function getPageMeta($paramArr) {
if (is_array($paramArr)) {
$options =
array(
'id' =>
0, #详情id
'indexFlag' =>
0, #首页标示
'noFollow' =>
0, #是否允许搜索引擎抓取
'noCache' =>
0, #是否缓存
'chartSet' =>
'GBK', #默认字符集
'pageType' =>
'', #页面类型,暂时没用到
'title' =>
'', #页面标题
'keywords' =>
'', #页面关键字
'description' =>
'', #页面表述
);
$options =
array_merge($options, $paramArr);
extract($options);
}
#页面编码
$metaStr =
'<meta charset="' . $chartSet .
'" />' .
"\n\t";
if($indexFlag ==
true){ #首页
$metaStr.=
'<meta http-equiv="mobile-agent" content="format=html5; url=http://m.zol.com.cn/z/" />' .
"\n\t";
}else if($pageType ==
'Detail' ){#详情页
$metaStr.=
'<meta http-equiv="mobile-agent" content="format=html5; url=http://m.zol.com.cn/article/'.$id.
'.html" />' .
"\n\t";
}
if (!
empty($noFollow)) { #如果不允许搜索引擎抓取
$metaStr .=
'<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />' .
"\n\t";
}
if (!
empty($noCache)) { #如果不允许缓存
$metaStr .=
'<meta http-equiv="pragma" content="no-cache" />' .
"\n\t";
}
if (!
empty($title)) { #如果有标题
$metaStr .=
'<title>' . $title .
'</title>' .
"\n\t";
}
if (!
empty($keywords)) { #如果有关键字
$metaStr .=
'<meta name="keywords" content="' . $keywords .
'" />' .
"\n\t";
}
if ($description) { #如果有描述
$metaStr .=
'<meta name="description" content="' . $description .
'" />' .
"\n";
}
#所有pc端页面禁止转码并且声明设备
$metaStr .=
'<meta http-equiv="Cache-Control" content="no-siteapp"/>'.
"\n\t";
$metaStr .=
'<meta http-equiv="Cache-Control" content="no-transform"/>'.
"\n\t";
$metaStr .=
'<meta name="applicable-device" content="pc">'.
"\n\t";
return $metaStr;
}
转载于:https://www.cnblogs.com/doubilaile/p/9176511.html
相关资源:PHP自动跳转 header和Meta以及script各方法