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

Linux下查看版本號指令

Linux下查看版本號指令

lsbrelease a ssss5 其他指令查詢方式 [root@localhost ~]# un...

使用PHP取得目前網址方式

使用PHP取得目前網址方式

pexelsphoto55 使用PHP取得網址相關的方式有下列幾種: $SERVER["R...

利用 .htaccess 限制可瀏覽ip來源

利用 .htaccess 限...

要如何限制某個資料夾內容只能給特定IP讀取? 這個部分其實可以透過.htaccess快速實現~ 首先...

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