Although you can set the error display to hide the hint, but there are also hidden dangers, that is, in the log of the server will be recorded in these prompts, resulting in unusually large log files.
First of all, this is not a mistake, it is warning. So if the server cannot be changed, each variable should be defined before it is used. There are several popular solutions on the Web:
Method 1: Server configuration modification. Modify php.ini configuration file, error_reporting = E_all & ~e_notice.
Method 2: Initialization of the variable, specification writing (more cumbersome, because there are a large number of variables). But have not found a good definition method, hope everyone advice.
Method 3: Each file head plus: error_reporting (0); If not, only open php.ini, find display_errors, set to Display_errors = off. Any future errors are not prompted.
Method 4: Make a Judgment: isset ($_get["page")) If-else judgment. or add ' @ ' to indicate the line if there are errors or warnings do not output. such as: @ $page =$_get["page"]
Method 5:file1.php file $xx variable to pay a value, by post to file2.php, if file2.php without $xx definition, and directly use $yy= $xx; The system will be an error: "Undifined variaable $xx", if the file2.php file started with $xx= ""; definition, then file1.php $xx value can not be passed. File2.php can be like this: if (!isset ($xx)) $xx = "";
If you think the above method is not good, you can also use the following method:
Copy Code code as follows:
function _get ($STR) {
$val =!empty ($_get[' str '])? $_get[' str ']: null;
return $val;
}
Define a function like this, and then use the _get (' str ') instead of $_get[' str ' just to make it easier.