0

我正在尝试在 $data['message'] 中设置动态消息

例如,假设在登录表单上我想显示消息,请输入用户名和密码,但在注销操作时显示你是成功的。登出。

所以我在想

function login()
{
   $data['message'];
   if(!isset $data['message'])
   {
      $data['message'] = "please enter your username and password";
   }
   $this->load->view('login' $data);
}

function logout()
{
   unset session and .....
   $data['message'] = "You were succ. logged out!";
   $this->login($data);
}

但我在渲染登录方法上遇到以下错误

Parse error: syntax error, unexpected T_VARIABLE, expecting '('

内线if(!isset $data['message'])

4

2 回答 2

2
if(!isset($data['message']))
 { //etc...

isset 需要括号

于 2013-05-25T12:19:01.980 回答
0

你可以试试这样..你忘了支架isset

function login()
    {
       $data['message'];
       if(!isset($data['message']))
       {
          $data['message'] = "please enter your username and password";
       }
       $this->load->view('login' $data);
    }

    function logout()
    {
       //unset session and .....
       $data['message'] = "You were succ. logged out!";
       $this->login($data);
    }
于 2013-05-25T12:22:52.310 回答