我自己用PHP写的一个极简单的 HTML 框架。

我写这个框架的目的很简单,我们做一些很小的工作的时候没必要弄个庞然大物来帮忙。我的宗旨是杀鸡绝不用牛刀。也希望能与有此想法的朋友交流提高。

<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */

/**
 * html 框架
 *
 * PHP versions 5
 *
 * LICENSE: 完全开放,无任何约束。供学习、交流、参考。使用者与本人无任何经济与责任关系!
 *
 * @作者    马中周
 * @版本    1.0
 * @网址    http://blog.csdn.net/xiuligong
 */
class htmlFrame {
    /**
     * 页面编码
     */
    protected $isCharset="";
   
    /**
     * 文档标题
     */
    protected $isTitle="";
   
    /**
     * 动态加载的头部定义,如 : <link><meta>
     */
    protected $headImpregnate="";
   
    /**
     * 是需要加载的javascript脚本.
     */
    protected $dynamicScriptImpregnate="";
   
    /**
     * 用于加载脚本样式等 body参数。如:onLoad="";
     */
    protected $parameter="";
   
    // {{{ 构造函数
    /**
     * 参数说明:
     *         $charset 给 $isCharset 初始化
     *         $isTitle 给 $isTitle 初始化
     *         $headImpregnate 给 $headImpregnate 初始化
     *         $dynamicScriptImpregnate 给 $dynamicScriptImpregnate 初始化
     *         $dynamicScriptImpregnate 给 $dynamicScriptImpregnate 初始化
     *         $parameter 给 $parameter 初始化
     */
    public function __construct($charset = "",$isTitle = "",$headImpregnate = "",$dynamicScriptImpregnate = "",$parameter = ""){

        $this -> isCharset = $charset;
        $this -> isTitle = $isTitle;
        $this -> headImpregnate = $headImpregnate;
        $this -> dynamicScriptImpregnate = $dynamicScriptImpregnate;
        $this -> parameter = $parameter;

        if(empty($this -> isCharset)){
            echo "请设置你文档的语言编码!!";
            exit;
        }
           
        if(empty($this -> isTitle)){
            $this -> isTitle = "无标题页面";
        }
    }
   
    // }}}
    // {{{ htmlBegin();
   
    /**
     * html页面(html 文档)开始
     */
    public function htmlBegin(){
        echo "<?xml version=/"1.0/" encoding=/"{$this -> isCharset}/" ?>/n";
        echo "<!DOCTYPE html PUBLIC /"-//W3C//DTD XHTML 1.0 Strict//EN/" /"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd/">/n";
        echo "<html xmlns=/"http://www.w3.org/1999/xhtml/">/n";
    }
   
    // }}}
    // {{{ htmlHead()
   
    /**
     * 页面的头定义
     */
    public function htmlHead(){

        echo "  <head>/n";
        echo "      <meta http-equiv=/"Content-Type/" content=/"text/html; charset={$this -> isCharset}/" />/n";
        echo "      ".$this -> headImpregnate."/n";
        echo "      <title>{$this -> isTitle}</title>/n";
        echo "  </head>/n";
    }
   
    // }}}
    // {{{ htmlJavascript()
   
    /**
     * 页面中 javascript 定义部分
     */
    public function htmlJavascript(){
        echo $this -> dynamicScriptImpregnate."/n";
    }
   
    // }}}
    // {{{ htmlBody([$parameter])
   
    /**
     * 文档内容开始
     */
    public function htmlBody(){
        if(empty($this -> parameter)){
            echo "<body>/n";
        }else{
            echo "<body {$this -> parameter}>/n";
        }
    }
   
    // }}}
    // {{{ htmlFooter()
   
    /**
     * 页面的页脚
     */
    public function htmlEnd(){
        echo "</body>/n";
        echo "</html>";
    }
   
    // }}}
    // {{{ blankPage();
   
    /**
     * 空白页函数
     */
    public function blankPage(){
        $this -> htmlBegin();
        $this -> htmlHead();
        $this -> htmlBody();
        $this -> htmlEnd();
    }
   
    // }}}
   
}
?> 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值