|
-
Mar 26th, 2008, 02:19 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] How to properly handle "Undefined offset"?
What is the correct way to fix this?
The only option I have right now it to disable that particular notice in php.ini.
I am using is_null (but atm is_set would also work as far as functionality), but just sending that undefined offset using is_null sets off the error. Any trick to fixing this? Right now I am getting like 30-40, and I just started coding :P
Last edited by Zeratulsdomain; Mar 27th, 2008 at 08:05 AM.
-
Mar 26th, 2008, 06:57 PM
#2
Re: How to properly handle "Undefined offset"?
I assume you are using strict mode. This is a good thing. Don't disable warnings; fix the code.
You can use isset() or array_key_exists() to determine if an offset exists. There is a very subtle difference between the two which doesn't matter in most cases.
is_null() will not work — this actually attempts to read the array offset, and so fails if it does not exist.
-
Mar 27th, 2008, 08:05 AM
#3
Thread Starter
Hyperactive Member
Re: How to properly handle "Undefined offset"?
weird, thought I had tried isset, but just tried it again and it worked, tnx.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|