父类设置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>
父类设置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>
<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></code>