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

當XAMPP遇到VMWARE占用PORT 443導致無法啟動APACHE

當XAMPP遇到VMWARE...

在使用XAMPP時,若系統有安裝 VMWare Workstation,VMWare會將 port ...

Android Fragment及Activity 中使用sharedpreferences

Android Fragme...

在Android下想要儲存執行資料的方式有好幾種,例如存在手機空間或者是資料庫空間。 這裡紀錄一下使...

WordPress如何關閉迴響留言功能?

WordPress如何關閉迴...

其實WordPress本身的留言迴響功能還蠻健全的。 包括可以設定關鍵字黑名單或者是IP黑名單,強制...

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