宣佈我創造我的登錄頁面,當我裝起來我似乎得到這個錯誤說:致命錯誤:不能重新聲明電子郵件()之前在
Fatal error: Cannot redeclare email() (previously declared in /home/a4625512/public_html/core/functions/general.php:2) in /home/a4625512/public_html/core/functions/general.php on line 4
我的主人是000webhost的,所以我不知道它是否與他們有關, 和我在網上搜索到處都是。
general.php代碼:
function email($to, $subject, $body) {
mail($to, $subject, $body, 'From: [email protected]');
}
登錄代碼:
include 'core/init.php';
if(empty($_POST) === false){
$username = $_POST['username'];
$password = $_POST['password'];
if(empty($username) === true || empty($password) === true){
$errors[] = 'You need to enter a username and password.';
}else if(user_exists($username) === false){
$errors[] = 'We cant find that username. Have you registered?';
}else if(user_active($username) === false){
$errors[] = 'You have not activated your account!';
}else{
$login = login($username, $password);
if($login === false){
$errors[] = 'That username/password is incorrect.';
}else{
$_SESSION['user_id'] = $login;
header('location: index.php');
exit();
}
}
print_r($errors);
}
錯誤消息說明了這一切。你不能重新聲明... –
我不知道如何解決這個問題 –
有幾個解決方案;你可以改變函數的名稱,或者使用命名空間來停止衝突,或者因爲'email'沒有被保留,所以你應該能夠使用它,你可以追查到函數email()已經被聲明的地方(提示:'核心/功能/一般。php:2'),如果沒有使用,請將其刪除 – Mikey