我正在尝试在$ data ['message']
中设置动态消息 例如,假设在登录表单上我想显示消息,请输入用户名和密码,但是在注销操作上显示你是succ。退出。所以我在想
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'])
答案 0 :(得分:2)
if(!isset($data['message']))
{ //etc...
isset需要括号
答案 1 :(得分: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);
}