PHP prompts several solutions for undefined index!

Source: Internet
Author: User

The above are PHP prompts rather than error reports. php can be directly used without declaring the variables in advance, but there will be prompts for not declaring the variables.

Solution:

1. Modify the error display mode of errror in PHP. ini.

Change error_reporting = e_all

Error_reporting J = e_all &~ E_notice

Restart the server.

 

2. Variable Initialization

 

3. Determine Variables

Isset ($ _ post ['']), empty ($ _ post ['']) If -- else

4. Add @ before the notice code, indicating that an error or warning is returned.

 @$word = $_POST['word'];

5. Last Method

Define a function:

 

function _get($str){ $val = !empty($_GET[$str]) ? $_GET[$str] : null; return $val; } 

You can call it every time, such as _ Get ('str') instead of $ _ Get ['str'].

[PHP-core-Error]

Error_reporting = e_all &~ E_notice
The error report level is the superposition of bit fields. We recommend that you use e_all | e_strict
; 1 e_error fatal runtime error
; 2 e_warning runtime warning (non-fatal error)
4. parsing error during e_parse Compilation
; 8 e_notice runtime reminder (often a bug or intentionally)
; 16 e_core_error fatal error during PHP startup
32 _ core_warning warning during initialization (non-fatal error) during PHP startup)
; 64 e_compile_error fatal error during compilation
; 128 e_compile_warning warning during compilation (non-fatal error)
256 User-Defined fatal error
; 512 user_warning User-Defined warning (non-fatal error)
1024 e_user_notice User-Defined notifications (often bugs, or intentionally)
; 2048 e_strict code standardization warning (how to modify to forward compatibility)
; 4096 e_recoverable_error is close to a fatal runtime error. If it is not captured, it is treated as e_error.
; 6143 all except e_strict errors (8191 in PhP6, that is, all errors)
Detailed source reference: http://www.jb51.net/article/30328.htm

 

 

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.