PHP框架方便调试修改模版的一种写法

/**
 * 输出模板
 *
 * @param  string $_name    模板文件名称(含扩展名)
 * @param  string $_dir     模块名称
 * @return  void
 */
public function display($_name, $_dir = NULL) {

    // 处理变量
    $this->_options['ci'] = $this->ci;
    if (!$this->_options['my_web_url']) {
        $this->_options['my_web_url'] = dr_now_url();
    }
    extract($this->_options, EXTR_PREFIX_SAME, 'data');
    $this->_options = NULL;
    $this->_filename = $_name;

    // 加载编译后的缓存文件
    $poscms_tpl_file = $this->get_file_name($_name, $_dir);
    if (defined('SYS_DEBUG') && SYS_DEBUG) {
        echo "<!--当前页面的模板文件是:$poscms_tpl_file (本代码只在调试模式下显示)-->".PHP_EOL;
    }
    include $this->load_view_file($poscms_tpl_file);

    // 消毁变量
    $this->_include_file = NULL;
    if ($this->_set_mobile_file) {
        $this->_tname = $this->mobile ?  'mobile' : 'pc';
        $this->_set_mobile_file = 0;
    }

}

image.png摘自POSCMS3框架

支付宝扫码打赏 微信扫码打赏

如果本文对你有帮助,欢迎打赏本站

喜欢 ()or分享
    匿名评论
  • 评论
人参与,条评论