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
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
Try to check if the variable is set before using it as an argument.
$get = isset( $set['id']) ? $this->settings[$set['id']] : '';
Maybe, $set['id']
must check, like this:
$set_ = isset($set['id']) ? $set['id'] : '';
$value = isset($this->settings[$set_]) ? $this->settings[$set['id']] : '';
I would simply add it to the isset call
$get = isset( $set['id'],$this->settings[$set['id']]) ? $this->settings[$set['id']] : '';
You can use multiple arguments in isset. This is roughly equivalent to doing this:
$get = isset($set['id']) && isset($this->settings[$set['id']]) ? $this->settings[$set['id']] : '';
This can be easily tested with this code:
$array = ['foo' => 'bar'];
$set = []; //not set
#$set = ['id' => 'foo']; //uncomment to test if set
#using [] to add an element to a string not an array
$get = isset($set['id'],$array[$set['id']]) ? $array[$set['id']] : '';
echo $get;
When $set = ['id' => 'foo']
the output is bar
if you leave that commented then the output is an empty string.