**php notice:undefined Index: ... How to solve the problem

Source: Internet
Author: User

This problem may be caused by undefined variables:

if (!empty ($current _user_id)) {
$digg = $this->m_feed_digg->show_entity (Array (' digg_user_id ' = = $current _user_id, ' digg_feed_id ' = = $ result[$feed _key][' feed_id '));
if (!empty ($digg)) {
$result [$feed _key][' Is_digg '] = true;
$result [$feed _key][' digg_id '] = $digg [' digg_id '];
}else{
$result [$feed _key][' Is_digg '] = false;
$result [$feed _key][' digg_id '] = $digg [' digg_id '];
;
}

}

The problem above is that $digg is empty, so
$digg [' digg_id '] must be undefined, this should be changed to NULL

----------------------------------------------------------------------

First of all, this is not a mistake, it is warning. Therefore, if the server cannot be changed, each variable should be defined before use.

Method 1: Server configuration Modifications
Modify the php.ini configuration file, error_reporting = E_all & ~e_notice

Method 2: Initialize the variables, standardize the writing (more cumbersome, because there are a lot of variables). But have not found a good definition method, I hope you advise

Method 3: Each file header plus: error_reporting (0); If not, only open php.ini, find display_errors, set to Display_errors = Off. Any future errors will not be prompted.

Method 4: Make a Judgment: isset ($_get["page"]) If-else judgment

or add "@" to indicate this line if there is an error or warning do not output
such as: @ $page =$_get["page"]

Method 5:file1.php file to pay a value $xx variable, with post to file2.php,
If the file2.php does not have the definition of $xx, the direct use of $yy= $xx; The system will be error: "Undifined variaable $xx", if file2.php's files start with $xx= ""; definition, then file1.php $xx value will not pass!

File2.php can do that.
if (!isset ($xx)) $xx = "";

**php notice:undefined Index: ... How to solve the problem

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.