__Contruct()錯誤
<?php namespace?app\index\controller; use?think\Controller; use?think\Request; class?Index?extends?Controller { ????public?function?__construct(){ ????????config('before',?'beforeAction'); ????} ????public?function?index(Request?$request) ????{ ????????return?$this->fetch(); ????} }
上面的代碼,直接跑會報一個‘
Call to a member function fetch() on a non-object
’的錯誤,但是刪除掉construct函數(shù)后就沒問題了,請問這個是怎么沒一個情況?
2017-09-14
你需要添加一行? parent::__construct();