<?php
header("Content-type:text/html;charset=utf-8");class template {
public $_var;
public $_content;
public $_fileName = 'index.html';
public $left_delimeter = '[[';
public $right_delimeter = ']]';
function getContent($file_name) {
return $this->_content = file_get_contents($file_name);
}
function assign($key, $value) {
if (!empty($key))
$this->_var[$key] = $value;
}
function display() {
$this->getContent($this->_fileName);
preg_match_all('/\[\[(.*?)\]\]/', $this->_content, $match);
if (!empty($match[1]) && !empty($match[0])) {
foreach($match[1] as $tag) {
$this->_content = str_replace($this->left_delimeter . $tag . $this->right_delimeter, $this->_var[$tag], $this->_content);
}
}
echo $this->_content;
}
}$t = new template();
$t->assign('LEFT_BLOCK', '<div id="left_block" style="width:200px;height:200px;background-color:#00f;">Left</div>');
$t->assign('RIGHT_BLOCK', '<div id="right_block" style="margin-top:20px;width:200px;height:200px;background-color:#00f;">Right</div>');
$t->display();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货