tp5重点知识

自动设置时间戳,update_time和create_time

$protected $autoWriteTimestamp=true;

软删除(需要delete_time字段):

use traits\model\SoftDelete;
use SoftDelete;

获取被软删除的

User::withTrashed(true)->find(13);

获取全部被删除的数据

User::onlyTrashed()->select();

设置默认返回类型

use think\Config;
Config::set('default_return_type','json');
use think\Controller;
$this->assgin('name','changweining');
 {$Think.server.DOCUMENT_ROOT}</p> <p>{$Think.server.DOCUMENT_ROOT}

Server方面的

{$Think.session.email}
{$Think.session.email}
{$Think.cookie.name}
{$Think.get.id}

进行md5

<p>{$user|md5}</p>

截取,substr=开始,截取长度是几

 <p>{$user|substr=0,8}</p>
 <p>{$time|date="Y-m-d H:i:s",###}</p>
$list = [ 
  'user1'=>[ 'name' => 'changweining', 'tel' => '15210687833' ], 
  'user2'=>[ 'name' => 'lixiaohui', 'tel' => '15210687833' ],
  'user3'=>[ 'name' => 'linwuxin', 'tel' => '15210687833' ]
];
 $this->assign('list',$list);

{volist name='list' id='vo' offset='1'}
<p>{$vo.name}</p>
{/volist}
 {for start='1' end='10000'} {for start='1' end='10000'} <p>{$i*$i}</p> {/for}
{switch name="Think.get.level"}

    {case value='1'} <p>普通会员</p> {/case} 

    {case value='2'} <p>高级会员</p> {/case} 

    {default /} <p>哈哈</p>

 {/switch}
点赞