PhpNotice: Undefinedindex error prompt solution

Source: Internet
Author: User
The literal meaning is an undefined index, which is generally caused by the inaccuracy of the developer's judgment. Generally, the running of the program is not affected. For specific solutions, refer.

The literal meaning is an undefined index, which is generally caused by the inaccuracy of the developer's judgment. Generally, the running of the program is not affected. For specific solutions, refer.

Method 1: If normal execution of the program is not affected, use the blocking method.

You can add
Error_reporting (E_ALL ^ E_NOTICE );

Disable NOTICE error warning

Method 2: locate the Specific Row and solve the problem as prompted.
For example, elseif ($ _ POST ['strue'] = 'OK'), a Hong Kong Vm, such as the code above, Hong Kong Space, has not submitted the istrue, so there must be a problem.

You can use the following code to solve the problem:
First Judge

The Code is as follows:


If (array_key_exists ('strue ', $ _ POST ))
{
If ($ _ POST ['strue'])
{
$ Istrue = $ _ POST ['strue'];
}
} Else {
$ Istrue = '';
}


The following judgment can be made:

The Code is as follows:


Elseif ($ istrue = 'OK ')


To avoid such errors, you can refer to some program systems for the Hong Kong Space.
For details, refer to the dedecms live phpcms code.

The Code is as follows:


// Check and register external submitted Variables
Foreach ($ _ REQUEST as $ _ k => $ _ v)
{
If (strlen ($ _ k)> 0 & eregi ('^ (cfg _ | GLOBALS)', $ _ k ))
{
Exit ('request var not allow! ');
}
}
Function _ RunMagicQuotes (& $ svar)
{
If (! Get_magic_quotes_gpc ())
{
If (is_array ($ svar ))
{
Foreach ($ svar as $ _ k = >$ _ v) $ svar [$ _ k] = _ RunMagicQuotes ($ _ v );
}
Else
{
$ Svar = addslashes ($ svar );
}
}
Return $ svar;
}

Foreach (Array ('_ get',' _ Post', '_ COOKIE') as $ _ request)
{
Foreach ($ _ request as $ _ k = >$ _ v) $ {$ _ k} = _ RunMagicQuotes ($ _ v );
}
If (empty ($ istrue ))
{
$ Istrue = '';
}

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.