文章出處

 1 <?php
 2 namespace app\controllers;
 3 use yii\web\Controller;
 4 
 5 
 6 class HelloController extends Controller {
 7     public function behaviors() {
 8         return[
 9             [
10                 'class'=>'yii\filters\PageCache', //頁面緩存
11                 'duration'=>1000,//緩存時間
12                 'only'=>['index','test'], //緩存的頁面
13                 'dependency'=>[     //緩存依賴
14                     'class'=>'yii\caching\FileDependency',
15                     'fileName'=>'hw.txt'
16                 ]
17             ]
18         ];
19     }
20     public function actionIndex()
21     {
22       echo '5';
23 //        return $this->render('index');
24     }
25     public function actionTest() {
26         echo '4';
27     }
28 }

其中 behaviors() 方法會優先于其它的function


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()