When you use $_post['],$_get[' to get the parameters in the form
Notice : Undefined index:--------;
We often receive forms POST the data Times undefined index error, as follows: $act =$_post[' action ';
Always prompt with the above code
notice:undefined index:act in D:\test\post.php on line 20
In addition, there are sometimes
Notice:undefined Variable:submit ... Wait for some of these tips
These are the PHP tips instead of an error, and PHP itself does not need to declare variables in advance to be used directly, but there are hints for undeclared variables. Generally as a formal website will be the prompt to turn off, and even the error message is also turned off.
Workaround:
Method 1: Server configuration Modifications
Modify the error display mode in php.ini in the errors configuration: Change error_reporting = E_all to
error_reporting = E_all & ~e_notice
After the modification, restart the Apche server before it can take effect.
Method 2: Initialize the variable.
Method 3: Make a judgment Isset ($_post["]), Empty ($_post[")) if--else
Method 4: Add @,@ before the notice code to indicate that the line has errors or warnings do not output, @ $username =$_post[' username '];
Precede the variable with an @, such as if (@$_get[' action ']== ' save ') {...
Method 5: The last one is very practical, is a function written by others, through this function to pass the value.
Define a function:
Copy CodeThe code is as follows:
function _get ($STR) {
$val =!empty ($_get[$str])? $_get[$STR]: null;
return $val;
}
Then use _get (' str ') instead of $_get[' str ').
[Php-core-error]
error_reporting = E_all & ~e_notice
; Error reporting level is an overlay of bit fields, it is recommended to use E_all | E_strict
; 1 E_error Fatal Run-time error
; 2 e_warning Runtime Warning (non-fatal error)
; 4 E_parse Compile-time parse error
; 8 E_notice Runtime Reminders (often bugs, may also be intentional)
; E_core_error PHP startup fatal error during initialization
; e_core_warning PHP Startup warnings during initialization (non-fatal error)
; E_compile_error compile-time fatal error
; E_compile_warning Compile-time warning (non-fatal error)
; E_user_error user-defined fatal error
; E_user_warning user-defined warning (non-fatal error)
; 1024x768 E_user_notice user-defined reminders (often bugs, may also be intentional)
; 2048 E_strict Coding Normalization Warning (recommended how to modify to forward compatible)
; 4096 E_recoverable_error near-fatal run-time error, if not captured, is considered the same as E_error
; 6143 e_all All errors except E_strict (8191 in PHP6, including all)
http://www.bkjia.com/PHPjc/325444.html www.bkjia.com true http://www.bkjia.com/PHPjc/325444.html techarticle usually use $_post['],$_get['] to get the parameters in the form notice:undefined index:--------; We often receive forms post data Times Undefined index errors, as follows: ...