taglib扩展标签无法加载Class Db类

浏览:581 发布日期:2017/03/29 分类:ThinkPHP5专区 关键字: taglib 扩展标签 Db类
以下代码<?php

namespace app\common\taglib;
use think\Db;
use think\template\TagLib;

class TagLibFront extends TagLib{
    /**
     * 定义标签列表
     */
    protected $tags   =  [
        // 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次
        'close'     => ['attr' => 'time,format', 'close' => 0], //闭合标签,默认为不闭合
        'open'      => ['attr' => 'name,type', 'close' => 1], 
        'loop'      => ['attr' => 'table,where,order,limit,relation,field,result,page,purl,purlvars', 'close' => 1], 

    ];
 /**
     * 这是一个非闭合标签的简单演示
     */
    public function tagOpen($tag, $content)
    {
        $type = empty($tag['type']) ? 0 : 1; // 这个type目的是为了区分类型,一般来源是数据库
        $name = $tag['name']; // name是必填项,这里不做判断了
        $parse = '<?php ';
        $parse .= '$test_arr=[[1,3,5,7,9],[2,4,6,8,10]];'; // 这里是模拟数据
        $parse .= 'Db::name("table");';
        $parse .= '$__LIST__ = $test_arr[' . $type . '];';
  
        $parse .= ' ?>';
        $parse .= '{volist name="__LIST__" id="' . $name . '"}';
        $parse .= $content;
        $parse .= '{/volist}';
如下报错

这报错很神奇。。。
最佳答案
评论( 相关
后面还有条评论,点击查看>>