父類別設定session後 為什麼子類別繼承父類別後echo session('name');什麼都不顯示呢?
<code><?php namespace Home\Controller; use Think\Controller; class CommonController extends Controller{ public function __initialize(){ session('name','lili'); } } ?> <?php namespace Home\Controller; use Think\Controller; class UserController extends CommonController{ public function user(){ echo session('name'); } } </code>
父類別設定session後 為什麼子類別繼承父類別後echo session('name');什麼都不顯示呢?
<code><?php namespace Home\Controller; use Think\Controller; class CommonController extends Controller{ public function __initialize(){ session('name','lili'); } } ?> <?php namespace Home\Controller; use Think\Controller; class UserController extends CommonController{ public function user(){ echo session('name'); } } </code>
<code><?php namespace Home\Controller; use Think\Controller; class CommonController extends Controller{ public function __initialize(){ session('name','lili'); } } ?> <?php namespace Home\Controller; use Think\Controller; class UserController extends CommonController{ public function __initialize(){ parent::__initialize(); } public function user(){ echo session('name'); } }</code>