Possible Duplicate:
PHP: Notice: Undefined index where the session variable is defined
PHP: 「Notice: Undefined variable」 and 「Notice: Undefined index」PHP公告:未定義的索引錯誤與會話
好了,這是錯誤:
Notice: Undefined index: overview_id in C:\xampp\htdocs\site\home.php on line 6
這是我的代碼:
<?php session_start();
$sess = $_SESSION["overview_id"];
if(isset($sess)){
header("Location: account.php");
}
?>
任何幫助將是很酷。
謝謝。
$ _SESSION [ 「overview_id」]沒有定義。就像錯誤信息所示 – 2012-11-05 23:31:48
這不是一個錯誤,它是一個*通知*,它只是告訴你一些不錯的做法 –
我不明白它:如果你檢查'overview_id'元素是否被定義(你用'isset'來檢查它),爲什麼你要創建一個臨時變量,給它賦值,然後檢查這個變量?爲什麼不只是'if(isset($ _ SESSION ['overview_id']))'然後呢?我的意思是,這個邏輯背後的推理是什麼? – raina77ow