Notice: Undefined offset

Source: Internet
Author: User
Today I encountered such a problem.

Notice: Undefined offset: 20 in D:/appserv/www/newcoop/auto_check_date.php On Line 36

I believe many new PHP learners may also encounter notice: Undefined offset :...
This problem often occurs in arrays,ProgramIt can run correctly, but there will always be a prompt on the screen: Notice: Undefined offset :..... on the Internet, it is generally used to suppress the display of PHP. the error_repoting parameter in the INI file is "eall & Notice", so that the screen can be displayed normally.

The problem is solved, but it is hard to figure out the offset: Next number (for example, notice: Undefined offset: 4 ....) what does it mean. also, the syntax in the sentence is clearly correct. Why is there a warning. after calmly thinking several times and trying every possibility, I finally found the answer. offset: the subsequent number is an incorrect array subscript, which is generally beyond the value range of the array. For example, an array $ A [] has 10 elements, if $ A [10] is displayed, an error occurs (Notice: Undefined offset: 10 ....), because the subscript of the array starts from 0, the subscript of this array can only be 0 ~ 9. therefore, when such problems occur, do not rush to suppress the display method (more easily add "error_reporting" at the beginning of the current file (fill in offset: the next number); Be sure to pay attention to the array subscript you are using. Think carefully and the problem will be quickly solved!

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.