常见的变量输出有如下情况:

    1.在控制器中按如下方式赋值

    1. $this->assign('hello','Hello ThinkCMF!');
    2. return $this->fetch();

    在模板中:

    1. <div>{$hello}</div>

    2.在控制器中赋值数组变量

    1. $data = ['hello'=>'Hello ThinkCMF!','username'=>'老猫'];
    2. $this->assign('data',$data);
    3. return $this->fetch();

    在模板中:

    1. <div>{$data.hello}</div>
    2. <div>{$data.username}</div>

    3.在控制器中赋值对象变量

    1. $data = ['hello'=>'Hello ThinkCMF!','username'=>'老猫'];
    2. $data = json_decode(json_encode($data));
    3. $this->assign('data',$data);
    4. return $this->fetch();

    在模板中:

    1. <div>{$data:hello}</div>
    2. <div>{$data:username}</div>

    或:

    1. <div>{$data->hello}</div>
    2. <div>{$data->username}</div>

    原文: https://www.thinkcmf.com/docs/cmf/变量输出.html