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

Format JavaScript Date to yyyy-mm-dd

Format JavaScr...

timecalendar5 JavaScript將Sun May ,轉換成yyyymmdd func...

.htaccess與RewriteEngine一起使用時500內部服務器錯誤

.htaccess與Rewr...

在某些情況下,可能未加載apache中的modrewrite模塊。 這時只需要執行以下指令就可以獲得...

讓文字左右對齊

讓文字左右對齊

讓文字左右對齊這類的設計案,通常都會出現在平面設計居多。 網頁上很少會遇到客戶會執著於這方面,但不能...

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