ThinkPHP 笔记

1、查看版本号

\thinkphp\library\think\App.php

2、模板输出

目录结构

index.php 内容

<?php
namespace app\index\controller;

use think\Controller;

class Index extends Controller
{
    public function index(){              
       return $this->fetch();          
    }
}

2.1、模板 比较标签

{lt name="product.total_count" value="$product.min_count"}    
    <div class="ProductCountLow">
        库存不足:{$product.total_count}/{$product.min_count}
    </div>
{/lt}

{egt name="product.total_count" value="$product.min_count"}    
    <div class="ProductCount">
        库存:{$product.total_count}
    </div>
{/egt}

2.2、输出关联对象

public function unit(){
   return $this->belongsTo("CateProductUnitModel")->field("id","name");
}
{$product.unit.name}

 

3、路由

以下路由定义匹配,当访问 http://domain.com/index.php/product时,转到 http://domain.com/index.php/index/Product/index。写链接时别忘了index.php

Route::rule('product','index/Product/index');

4、常量问题

参考:https://blog.csdn.net/yiyuwu7069/article/details/78466400

5、文件上传