准備:
在index/controller下創建一個名為requests.php的文件(注意:不要起名為request,因為它是關鍵字,不被允許起名)
動態方法和靜態方法的區別:
靜態方法:public static function test(){}
動態方法:;public function test(){}
可以看出,他們的區別就是一個是靜態方法,一個是普通方法。
動態方法使用請求
通過url訪問:localhost/tp5的框架目錄/thinkpublic//index.php/index/requests/request?name='小倉鼠'&age=18
通過靜態代理使用
輸出結果:
通過依賴注入使用請求
結果:
通過Controller類中封裝好的屬性進行使用
結果:
以上
END