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

Why is an error reported in this initialization function? ?

WBOY
Release: 2016-10-22 00:14:27
Original
1461 people have browsed it

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login
<code>   #如果是调用 原生的 SESSION:
   $_SESSION['URL', CONTROLLER_NAME.'/'.ACTION_NAME];
   echo $_SESSION['URL'];</code>
Copy after login
Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template