Loading...

如何修復Undefined Index錯誤訊息

Temperature: 0 °C

Mark ChangMark Chang
author_tools

錯誤的原因是因為當我們使用 $_GET 和 $_POST 方法取得變數時會發生這種情況,雖然PHP的部分即使沒有宣告設置變數,我們也可以使用,但就是會出現錯誤訊息。
除非你想要把錯誤訊息隱藏例如在$_GET 和 $_POST前面加上@

但若要解決就可以使用 isset() 函數在引用之前檢查變數是否已宣告設置。
例如

if(isset($_GET['valuename'])){
$name = $_GET['valuename'];
}
if(isset($_POST['valuename'])){
$name = $_POST['valuename'];
}

又或者可以使用
$name = isset($_GET[‘valuename’]) ? $_GET[‘valuename’]: “Variable is not set”;

以上紀錄~
 

#故事  #isset  #php  #Undefined Index  
https://innstory.com/story-如何修復Undefined_Index錯誤訊息-3003
PHP

Prev
 js判斷字母是否為大小寫

Next
synology_nas_上如何解決Fatal_error_Call_to_undefined_function_exifreaddata 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

使用PHP mb_substr() 函式,擷取部分字串並記得使用UTF-8。

使用PHP mb_subst...

pexelsphotohello5 文字長度太長,一般來說我們可以使用DIV包住字串,再定義DIV的...

PHP–implode() 將陣列轉成字串

PHP–implode() ...

pexelsphoto 使用implode將陣列轉換成字串; $ar=array(&#;a&#;,&...

使用PHP取得指定月份最後一天的日期

使用PHP取得指定月份最後一...

使用PHP要如何抓某個月份的最後一天 例如抓本月份的話可以使用下列範例: date(&#;Ymt&#...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format