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

Android UI設計距離課題

Android UI設計距離...

layoutmarginTop指定該屬性所在控件距離上方的位置空間。 layoutmarginBot...

在PHP強制顯示錯誤訊息的方法

在PHP強制顯示錯誤訊息的方...

若是單一檔案,只需要在每個PHP檔案裡添加下列行: iniset(&#;displayerrors&...

修改apache設定

修改apache設定

pexelsphotolock5 進入apache資料夾,找到conf資料夾(預設是C:\AppSe...

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