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