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

Asked by jsherk

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:
Last query:
Last reply:
Revision history for this message
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...
}

Revision history for this message
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