我一直試圖讓這個工作整天,但它似乎並沒有工作。在$登錄變量被稱爲但它不影響if語句:調用一個非對象的未定義變量的成員函數:login
$login = new Login();
function inclu(){
if ($login->isUserLoggedIn() == true){
include (($_SERVER['DOCUMENT_ROOT']."/project/log/assets/displayuser.php"));
}
else {
// the user is not logged in. you can do whatever you want here.
// for demonstration purposes, we simply show the "you are not logged in" view.
include (($_SERVER['DOCUMENT_ROOT']."/project/log/assets/displaysign.php"));
};
}
它用錯誤的出現: 注意:未定義的變量:登錄在C:\ XAMPP \ htdocs中\項目\日誌\的index.php上線38
致命錯誤:調用一個成員函數isUserLoggedIn()一個非對象在C對:\ XAMPP \ htdocs中\上線項目\日誌\的index.php
您需要學習基本的PHP範圍規則。 'include()'函數中不存在'$ login'。閱讀並學習:http://www.php.net/manual/en/language.variables.scope.php –