Home >Backend Development >PHP Tutorial >Why is an error reported in this initialization function? ?

Why is an error reported in this initialization function? ?

WBOY
WBOYOriginal
2016-10-22 00:14:271457browse

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>

Reply content:

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>

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>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn