Php prompts Notice: Undefined index error Solution

Source: Internet
Author: User

This problem occurs when you enable the error prompt in php, you will be notified of some programming errors. Next I will analyze the php Notice: Undefined index error prompt Method for you, for more information, see.

Cause Analysis

This problem is generally caused by undefined variables.

Example

The Code is as follows: Copy code

If ($)
{
Echo $;
}
Else
{

}

// Prompt: Notice: Undefined variable: a in E:/www/test. php on line 5

The Code is as follows: Copy code


// Solution

$ A = 1;
If ($)
{
Echo $;
}
Else
{

}

// Output 1
// Add it to the header of the article

Error_reporting (0 );

If ($)
{
Echo $;
}
Else
{

}

Solution Summary

1. If a variable does not apply for a direct name, such as $ a = 1.
2. Add error_reporting (0) to the header of the article. No errors are prompted.
3. isset ($ _ GET ["page"]) or: @ $ page = $ _ GET ["page"]
4. Use error_reporting = E_ALL & ~ in php. ini &~ E_NOTICE can disable the display of notice, so it is good to block such warnings,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.