The company keeps their PHP errors suppressed in code, but I turned it on to see why something of mine was not working.
Now, however, I am getting hundreds of Undefined index
messages that I would like to turn off so that I can find the messages from MY code.
Here is one particular block that gives many errors:
final public function getAttribute($name) {
$value = '';
if(is_array($this->attributes[$name]) === false) { // Notice: Undefined index: name
$value = trim($this->attributes[$name]);
} else {
$value = trim(implode(' ', $this->attributes[$name]));
}
return $value;
}
To eliminate these notices, I followed the post Why check both isset() and !empty() to write it like this:
final public function getAttribute($name='') {
if (!isset($name) || empty($name)) {
return '';
}
$value = '';
if(is_array($this->attributes[$name]) === false) { // Notice: Undefined index: name
$value = trim($this->attributes[$name]);
} else {
$value = trim(implode(' ', $this->attributes[$name]));
}
return $value;
}
I still get the notices, and in the same place.
How do I fix the code so that it does not create this condition?