午夜91福利视频,午夜成人在线观看,午夜在线视频免费观看,午夜福利短视频,精品午夜成人免费视频APP

前置操作

可以為某個或者某些操作指定前置執行的操作方法,設置 beforeActionList屬(shu)性可以指(zhi)定某個方法(fa)(fa)為其(qi)他方法(fa)(fa)的(de)前(qian)(qian)置操作,數組鍵名(ming)為需要(yao)調用的(de)前(qian)(qian)置方法(fa)(fa)名(ming),無值的(de)話為當前(qian)(qian)控制器下所有方法(fa)(fa)的(de)前(qian)(qian)置方法(fa)(fa)。

['except' => '方法名(ming),方法名']

表示這些方法不(bu)使用前置方法,

['only' => '方法名,方法名']

表示只有這些(xie)方法(fa)使用前置方法(fa)。

示例如下:

namespace app\index\controller;

use think\Controller;

class Index extends Controller
{
    protected $beforeActionList = [
        'first',
        'second' =>  ['except'=>'hello'],
        'three'  =>  ['only'=>'hello,data'],
    ];
    
    protected function first()
    {
        echo 'first<br/>';
    }
    
    protected function second()
    {
        echo 'second<br/>';
    }
    
    protected function three()
    {
        echo 'three<br/>';
    }

    public function hello()
    {
        return 'hello';
    }
    
    public function data()
    {
        return 'data';
    }
}

訪問

http://localhost/index.php/index/Index/hello

最后的輸出(chu)結果是

first
three
hello

訪問

//localhost/index.php/index/Index/data

的輸出結果(guo)是:

first
second
three
data
文檔最后更新時間:2018-04-26 08:32:40

文檔
目錄(lu)

深色
模式

切換
寬度