【php开源代码栏目提醒】:网学会员,鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“View.class.php”一文,供大家参考学习!
<?php
// +----------------------------------------------------------------------
// | ThinkPHP
// +----------------------------------------------------------------------
// | Copyright (c) 2008 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id$
/**
+------------------------------------------------------------------------------
* Think
PHP 瑙嗗浘杈撳嚭
* 鏀寔缂撳瓨鍜岄〉闈㈠帇缂?
+------------------------------------------------------------------------------
* @category Think
* @package Think
* @subpackage Core
* @author liu21st <liu21st@gmail.com>
* @version $Id$
+------------------------------------------------------------------------------
*/
class View extends Base
{
/**
+----------------------------------------------------------
* 妯℃澘椤甸潰鏄剧ず鍙橀噺锛屾湭缁忓畾涔夌殑鍙橀噺涓嶄細鏄剧ず鍦ㄩ〉闈腑
+----------------------------------------------------------
* @var array
* @access protected
+----------------------------------------------------------
*/
protected $tVar = array();
protected $trace = array();
// 浣跨敤鐨勬ā鏉垮紩鎿庣被鍨?
protected $type = '';
/**
+----------------------------------------------------------
* 鍙栧緱妯℃澘瀵硅薄瀹炰緥
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return Template
+----------------------------------------------------------
*/
static function getInstance() {
return get_instance_of(__CLASS__);
}
// 鏋勯犲嚱鏁?
public function __construct($type='') {
if(!empty($type)) {
$this->type = $type;
}else{
$this->type = strtoupper(C('TMPL_ENGINE_TYPE'));
}
}
/**
+----------------------------------------------------------
* 妯℃澘鍙橀噺璧嬪?
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param mixed $name
* @param mixed $value
+----------------------------------------------------------
*/
public function assign($name,$value=''){
if(is_array($name)) {
$this->tVar = array_merge($this->tVar,$name);
}else {
$this->tVar[$name] = $value;
}
}
/**
+----------------------------------------------------------
* Trace鍙橀噺璧嬪?
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param mixed $name
* @param mixed $value
+----------------------------------------------------------
*/
public function trace($title,$value='') {
if(is_array($title)) {
$this->trace = array_merge($this->trace,$title);
}else {
$this->trace[$title] = $value;
}
}
/**
+----------------------------------------------------------
* 鍙栧緱妯℃澘鍙橀噺鐨勫?
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $name
+----------------------------------------------------------
* @return mixed
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function get($name){
if(isset($this->tVar[$name])) {
return $this->tVar[$name];
}else {
return false;
}
}
private function __set($name,$value) {
$this->assign($name,$value);
}
private function __get($name) {
return $this->get($name);
}
/**
+----------------------------------------------------------
* 鍔犺浇妯℃澘鍜岄〉闈㈣緭鍑?鍙互杩斿洖杈撳嚭鍐呭
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $templateFile 妯℃澘鏂囦欢鍚?鐣欑┖涓鸿嚜鍔ㄨ幏鍙?
* @param string $charset 妯℃澘杈撳嚭瀛楃闆?
* @param string $conten