?? class.template.php
字號:
<?
#**************************************************************************#
# Very Simple Template Class
# -------------------------------------------------------------------
# By: ToToDoDo Email: ToToDoDo#GmAiL.com
#**************************************************************************#
class verySimpleTemplate{
var $template = "";
var $assigned = array();
//-----------------------------------------
// deal with the template and assign
//-----------------------------------------
function deal( $templatePath, $arrayAssigned = array() )
{
$this->template = $templatePath;
$this->assigned = $arrayAssigned;
$this->_loadTemplate();
$this->_parseTemplate();
}
//-----------------------------------------
// load template from file
//-----------------------------------------
function _loadTemplate()
{
if ( file_exists( $this->template ) )
{
if ( $FH = fopen( $this->template, 'r') )
{
$this->template = fread( $FH, filesize( $this->template ) );
fclose( $FH );
}
else
{
echo "Couldn't open the template file";
}
}
else
{
echo "Template file does not exist";
}
}
//-----------------------------------------
// parse the array assign
//-----------------------------------------
function _parseTemplate()
{
foreach( $this->assigned as $word => $replace)
{
$this->template = preg_replace( "/\{$word\}/i", "$replace", $this->template );
}
}
//-----------------------------------------
// output
//-----------------------------------------
function output()
{
echo $this->template;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -