Although you can hide this prompt by setting the error display mode, there is also a risk that these prompts will be recorded in the server logs, resulting in a huge Log File exception.
First, this is not an error, it is warning. Therefore, if the server cannot be changed, each variable should be defined before use. There are several popular solutions on the Internet:
Method 1: Modify the server configuration. Modify the php. ini configuration file, error_reporting = E_ALL &~ E_NOTICE.
Method 2: Initialize the variables and write them in a standardized manner (complicated because there are a large number of variables ). However, we have not found a proper definition method.
Method 3: Add error_reporting (0) to the header of each file. If not, open php. ini, find display_errors, and set display_errors to Off. No errors will be prompted in the future.
Method 4: Determine if-else: isset ($ _ GET ["page. Or Add '@' to indicate that this line will not be output if there is an error or warning. For example: @ $ page = $ _ GET ["page"]
Method 5: The file1.php file pays a value for the $ xx variable and uses post to pass it to file2.php. If file2.php does not have a $ xx definition, it directly uses $ yy = $ xx; the system reports the error "undifined variaable $ xx". If the file2.php file is defined with $ xx = "";, the $ xx value of file1.php cannot be passed. In file2.php, you can: if (! Isset ($ xx) $ xx = "";
If you think the above method is not very useful, you can also use the following method:Copy codeThe Code is as follows: function _ get ($ str ){
$ Val =! Empty ($ _ GET ['str'])? $ _ GET ['str']: null;
Return $ val;
}
Define such a function. When using this function, replace $ _ get ['str'] With _ GET ('str ~ This makes it easier.