Judging by your protected keyword, you are trying to set an object property. According to PHP manual:
They are defined by using one of the keywords public, protected, or private, followed by a normal variable declaration. This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated.
In order to set your value, put it into the constructor:
class Settings
{
protected $settings;
public function __constructor() {
$this->settings = array(
'prefix' => $this->getPrefix(),
);
}
public function getPrefix() {
return "Hello, World!";
}
}
$this->settings['prefix'] = $this->getPrefix();in the constructor of the object.expression is not allowed as field of default value, so you cannot use expression as a default value