PHP warn, notice solutions for problems

Source: Internet
Author: User
PHP warn, notice problem solution


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.

Method 1: Server configuration Modifications
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, I hope you advise

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. Ini_set ("Display_errors", 0);

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:

?

The file1.php file pays a value for the $XX variable, which is passed to file2.php by post.
If the file2.php does not have the definition of $xx, the direct use of $yy= $xx; The system will be error: "Undifined variaable $xx", if file2.php's files start with $xx= ""; definition, then file1.php $xx value will not pass!

?

File2.php can do that.

if (!isset ($xx)) $xx = "";

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.