The first method: If it does not affect the normal execution of the program, you can use the shielding method
You can add
error_reporting(E_ALL ^ E_NOTICE);
Turn off the NOTICE error warning in the first line of the code
The second method: Positioning Go to the specific line and solve it according to the prompts.
For example, elseif ($_POST['istrue'] == 'ok'), as shown in the above code, does not submit istrue, so there must be a problem.
It can be solved with the following code
First judge the above
Copy the code The code is as follows:
if(array_key_exists( 'istrue',$_POST))
{
if($_POST[ 'istrue'])
{
$istrue=$_POST[ 'istrue'];
}
}else{
$istrue='';
}
Copy the code The code is as follows:
elseif ($istrue == 'ok')
Copy the code The code is as follows:
//Check and register externally 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 = '';
}
The above introduces the solution to the undefined php Notice: Undefined index error message, including the undefined content. I hope it will be helpful to friends who are interested in PHP tutorials.