Solutions for notice:undefined Offset

Source: Internet
Author: User
There are always error prompts when you debug your program today:

Notice: Undefined offset:23 in XXX. php on line8

Notice: Undefined offset:24 in XXX. php on line8

This problem is very often in the array, the program is able to run correctly, but on the screen there will always be such a hint: notice:undefined offset: ... The internet is commonly used to suppress the display of the method, that is, change the php.ini file error_repoting parameter is "Eall & Notice", so that the screen can be displayed normally.

The problem is solved, but I can't get through offset: what the next number (such as notice:undefined offset:24 ...) means. Also, the syntax of the sentence is clearly correct and why there is a warning. Calmly thinking for several times and trying every possible, Finally found the answer. Offset: The next number is an error in the array subscript, is generally beyond the range of the array, such as the definition of the array $a[] There are 10 of the number of $a[10, if there is an error (notice:undefined offset:10 ...), Because the subscript of the array starts at 0, so the subscript of this array can only be 0~9. So in the case of this kind of problem, do not rush to suppress the display of the method (more simply can be in the front of the current file with a "error_reporting (offset: the next number); Be sure to pay attention to the array subscript you use, think carefully, the problem will soon be solved! It is possible to unset an array and then try to read its contents!

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.