Solution to PHP prompts notice:undefined variable

Source: Internet
Author: User

We know in PHP, variables usually do not need to define the direct use, but sometimes because of the PHP environment problems will appear all kinds of strange things, today in the debugger directly prompts notice:undefined variable error, This is because some variables are not defined as a result, but also dizzy, well, this problem directly a shielding wrong sentence is done.

Directly at the top of the program insert a sentence error_reporting (0); Believe that this problem will not be exposed, also do not delay the operation of the program, of course, this is only the emergency method, we still have to check the program where the problem, and then the right remedy, for direct screening of the summer blog to summarize several methods.

Modifications in the php.ini configuration file

302 lines of error_reporting = E_all in php.ini
Modified into
error_reporting = e_all & ~e_notice restart apache2.2.
Workaround: Modify PHP.ini
Will: error_reporting = E_all
Modified to: error_reporting = E_all & ~e_notice
If any errors do not want to show, directly modify:
Display_errors = Off
If you do not have php.ini permission to modify, you can add to the head of PHP:
Ini_set ("error_reporting", "E_all & ~e_notice");

Changes in the PHP file

If you do not have php.ini modification permission, you can add Ini_set ("error_reporting", "E_all & ~e_notice") to the head of PHP; or error_reporting (0);/can.

In general, directly recommended in the PHP file to add, this method is simple, do not have to modify the service side of the php.ini.

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.