我使用if语句运行以下代码。到目前为止我的语法看起来正确,但我得到一个错误说
Parse error: syntax error, unexpected ';'
at $request->session()->put('success');
看起来没问题。有人能告诉我哪里错了。 我的代码如下:
<?php
if (Hash::check($password, $hashedPassword->password)) {
$role_type = DB::select('select role_type from users where email = ?', [$email]);
if ($role_type === 'Administrator') {
$request->session()->put('success');
return redirect()->route('admin');
} else if ($role_type == - 'Staff') {
$request->session()->put('success');
return redirect()->route('staff');
} else ($role_type === 'User') {
$request->session()->put('success');
return redirect()->route('user');
};
} else {
return redirect()->route('login')->with('login_error', 'Invalid credentials entered');
};
答案 0 :(得分:3)
if
行中你遗失} else ($role_type === 'User') {
} else if($role_type === 'User') {
if (Hash::check($password, $hashedPassword->password)) {
$role_type = DB::select('select role_type from users where
email = ?', [$email]);
if ($role_type === 'Administrator') {
$request->session()->put('success');
return redirect()->route('admin');
} else if ($role_type == - 'Staff') {
$request->session()->put('success');
return redirect()->route('staff');
} else if($role_type === 'User') {
$request->session()->put('success');
return redirect()->route('user');
}
} else {
return redirect()->route('login')->with('login_error', 'Invalid
credentials entered');
}