Three ways to resolve notice:undefined index in PHP
Source: Internet
Author: User
Three solutions for notice:undefined index appearing in PHP
http://blog.csdn.net/stellaah/article/details/7631727
A PHP program done in the previous paragraph is running normally, when someone gets a native test, there is always a "notice:undefined index:" Warning, which is just a warning (Notice or warning), which is a different version of PHP, not an error ( ERROR). When the variables in PHP are used without declaration, the PHP4 runs normally, but in the PHP5 environment, the above warnings or prompts appear. After search query, summed up the following three ways to solve notice:undefined index.
The first method: Modify the PHP configuration file, block out such warnings and prompts to modify the php.ini configuration file, modify the error_reporting to Error_reporting = E_all & ~e_notice. Such procedures exist notice and warning shortcomings of the time will be ignored, of course, this is not suitable for beginners, not only inconvenient debugging procedures, and not conducive to the formation of good code habits.
The second method is to initialize each variable with a null value or any value, without affecting the operation. This is cumbersome for more variable programs, but it is a good practice to set the variable in advance each time, for example: $blank = ""; $price = "15″: $car =" Truck ":
The third method: [Email protected] is very easy, also very practical, the general second and the third combination of use.
The @ modifier suppresses the warning caused by a function call , but this modifier cannot suppress an error.
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