PHP undefined variable error how to solve?

Source: Internet
Author: User
Tags form post

When debugging the program, there may be undefined variable error, in general, PHP does not need to define variables, but if the server error, there will be errors, we often receive form post data times undefined index error is as follows : $act =$_post[' action '), or Always prompt notice:undefined index:act in D:\workspace\test.php on line 48. Additionally, sometimes notice is present: Undefined variable: $up ... Wait for some such hints, so the server should be shielded from this error. This behavior occurs because the variable is not defined.

Workaround, find the location of the php.ini:

1) in error_reporting settings: Find error_reporting = E_all modified to error_reporting = E_all & ~e_notice.

2) in Register_globals settings: Find register_globals = OFF; Modified to register_globals = on; Notice:undefined Variable:email in D:\PHP5\ENOTE\ADDNOTE. PHP on line 9.

In addition, we must note that after modifying the php.ini file, be sure to remember to restart Apache. Otherwise, the modification will not work.

If any errors do not want to let the display, directly modify: Display_errors = Off If you do not have php.ini Modify permissions, you can add Ini_set ("error_reporting", "E_all & ~e_notice" in the PHP header ); Can.

PHP undefined variable error how to solve?

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.