Use $_get["XX"] this form to obtain data, if not previously judged, $_get["XX" does not exist when the warning appears: PHP notice:undefined index XXX.
Although it is possible to hide this hint by setting the error display, there is a hidden danger that these prompts are logged in the server's log, causing the log file to be unusually large.
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. There are several ways to solve the popular problem online:
- Method 1: Server configuration modification. 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, hope everyone advice.
- 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 $xx variable to pay a value, with post to file2.php, if file2.php no $xx definition, and directly use $yy= $xx; The system will be error: "Undifined variaable $xx", if file2.php's file starts with $xx= "", then the file1.php value is not passed. File2.php can do this: if (!isset ($xx)) $xx = "";
If you think the above method is not very good, you can also use the following methods:
function _get ($str) { $val =!empty ($_get[' str '])? $_get[' str ']: null; return $val;}
Define such a function, and then use the _get (' str ') instead of the $_get[' str '] on the line ~ this will be convenient.
http://www.bkjia.com/PHPjc/752546.html www.bkjia.com true http://www.bkjia.com/PHPjc/752546.html techarticle use $_get["xx"] this form to obtain data, if not previously judged, $_get["XX" does not exist when the warning appears: PHP notice:undefined index XXX. Although can be set by wrong ...