我正试图在代码中插入一个常量define,这样,如果存在$error[],就可以插入对应define的字符串。就我而言:
if($user->login($username,$password)){
header('Location: memberpage.php');
$_SESSION['user_name'] = $username;
exit;
} else {
$error[] = 'Wrong username or password or your account has not been activated.';
}
定义常数
define ('ERROR_LOGIN', 'Wrong username or password or your account has not been activated.');
如何在$ERROR[]之后插入ERROR_LOGIN,以便在条件为false时返回其余部分?
感谢的帮助
您将常量存储到数组中,如下所示:
$error[] = ERROR_LOGIN;
DEMO