Home >Backend Development >PHP Tutorial >Why is an error reported in this initialization function? ?
<code><?php namespace Home\Controller; use Think\Controller; class CommonController extends Controller{ public function _initialize(){ echo seesion('URL', CONTROLLER_NAME.'/'.ACTION_NAME); } } ?></code>
<code><?php namespace Home\Controller; use Think\Controller; class CommonController extends Controller{ public function _initialize(){ echo seesion('URL', CONTROLLER_NAME.'/'.ACTION_NAME); } } ?></code>
Brother, you typed the word wrong, it’s session
not seesion
.
Looking at the namespace you used, functions should be encapsulated into classes.
The error session is not defined. I guess what you want to do is:
<code> #如果在 Controller 中定义 session: echo $this -> seesion('URL', CONTROLLER_NAME.'/'.ACTION_NAME);</code>
<code> #如果是调用 原生的 SESSION: $_SESSION['URL', CONTROLLER_NAME.'/'.ACTION_NAME]; echo $_SESSION['URL'];</code>