phpissetundefined-index

Although I use isset, I get an undefined index error


I know it asks too many time. But the isset function is not solve my problem.

$get = (isset($this->settings[$set['id']])) ? $this->settings[$set['id']] : '';

Notice: Undefined index: id in \public_html\settings.php on line 419


Solution

  • Maybe, $set['id'] must check, like this:

    $set_ = isset($set['id']) ? $set['id'] : '';
    $value = isset($this->settings[$set_]) ? $this->settings[$set['id']] : '';