zoukankan      html  css  js  c++  java
  • php页面meta头设置

    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 . '" />' . "
    	";
            if($indexFlag == true){ #首页
                $metaStr.= '<meta http-equiv="mobile-agent" content="format=html5; url=http://m.zol.com.cn/z/" />' . "
    	";
            }else if($pageType == 'Detail' ){#详情页
                $metaStr.= '<meta http-equiv="mobile-agent" content="format=html5; url=http://m.zol.com.cn/article/'.$id.'.html" />' . "
    	";
            }
            
            if (!empty($noFollow)) {  #如果不允许搜索引擎抓取
                $metaStr .= '<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />' . "
    	";
            }
    
            if (!empty($noCache)) {   #如果不允许缓存
                $metaStr .= '<meta http-equiv="pragma" content="no-cache" />' . "
    	";
            }
     
            if (!empty($title)) {     #如果有标题
                $metaStr .= '<title>' . $title . '</title>' . "
    	";
            }
    
            if (!empty($keywords)) {  #如果有关键字
                $metaStr .= '<meta name="keywords" content="' . $keywords .'" />' . "
    	";
            }
    
            if ($description) {       #如果有描述
                $metaStr .= '<meta name="description" content="' . $description .'" />' . "
    ";
            }
            #所有pc端页面禁止转码并且声明设备
            $metaStr .= '<meta http-equiv="Cache-Control" content="no-siteapp"/>'."
    	";
            $metaStr .= '<meta http-equiv="Cache-Control" content="no-transform"/>'."
    	";
            $metaStr .= '<meta name="applicable-device" content="pc">'."
    	";
            return $metaStr;
        }
  • 相关阅读:
    5.16
    4.29
    二十节 作业
    作业
    作业
    控件
    选择排序
    百钱买百鸡
    用颜色变色变换来调整图像的对比度和亮度
    图像的裁剪
  • 原文地址:https://www.cnblogs.com/doubilaile/p/9176511.html
Copyright © 2011-2022 走看看