Why can’t I set $_SERVER['DOCUMENT_ROOT'] as attribute?
see example code
class foo
{
private $path = $_SERVER['DOCUMENT_ROOT']; // generates error
private $blah;
public function __construct()
{
//code
}
public function setBla($bla)
{
$this->blah = $bla;
}
}
you cannot use other variable when initializing in declaration. try this:
by the way, are you sure private is an appropriate choice, often protected is preferable.