Usually when using $_post[''], $_get[''] to get the parameters in the form, Notice: Undefined index: --------;
Although You can hide this prompt by setting the error display mode, but this also has hidden dangers, that is, these prompts will be recorded in the server's log, causing the log file to be abnormally large.
Summarized several solutions through online searches and my own actual combat;
Method 1: Modify the server configuration
Modify the php.ini configuration file, error_reporting = E_ALL & ~E_NOTICE
Method 2: Initialize the variables.
Method 3: Make judgment isset($_post['']), empty($_post['']) if --else
Method 4: Add @ before the notice code appears, @ indicates that there is an error in this line Or warn not to output, @$username=$_post['username'];
Method 5: The last one is very practical. It is a function written by others, through which the value is transferred.
Define a function:
<span>function</span> _get($str){ $val = !<span>empty</span>($_GET[$str]) ? $_GET[$str] : null; <span>return</span> $val; }Copy after loginThen when using it, just use _get('str') instead of $_GET['str']~
The above introduces several solutions to php:undefined index, including undefined content. I hope it will be helpful to friends who are interested in PHP tutorials.