$this->security->get returns Undefined Index error

Asked by jsherk on 2011-01-13

When I use $this->security->post['some_item'] and some_item is not set, it works fine (no error), but when you use $this->security->get['some_item'] and some_item is not set it gives you a warning/notice that says:
Undefined index: some_item

Question information

Language:
English Edit question
Status:
Solved
For:
PHPDevShell Edit question
Assignee:
No assignee Edit question
Solved by:
jsherk
Solved:
2011-01-14
Last query:
2011-01-14
Last reply:
2011-01-14
TitanKing (titan-phpdevshell) said : #1

This in general is standard PHP behavior. You need to check variables are set be fore using them. The empty() function works well for this.

if (! empty($this->security->get['some_item'])) {
    // Do something...
}

jsherk (jeff-forerunnertv) said : #2

Yes I see... I realized that I was checking isset() for the post but not for the get... as soon as I added isset() around the get it worked fine!

Thanks