-2

I creating a class for generating a html web page. I am now facing an error. I can't find where I have done wrong maybe I have typo can anyone help me? I would be appreciated. It is something that I didn't declare or anything I didn't add into it.

 /*Singleton Design Pattern*/
class WEBPAGE{

private $title = "";
private $style = [];

/*Store Head, Body, Footer Content*/
private head = "";
private body = "";
private footer = "";

private function __constructor(){
    $this->$title = "";
    $this->$style = [];
}

private function styleGenerator($style){
    $generated_style = [];
}

private function styleTag($src){
    return '<link rel="stylesheet" href="'.$src.'">';
}

public static function getInstance()
{ 
    if(!self::$instance)
    {
        self::$instance = new self();
    }

    return self::$instance;
}

public function ouput(){
    //styleGenerator($this->$style);
    echo "My blank page";
}

}

?>

1 Answers1

0

Add $ sign to all before,missing $

private head = "";
private body = "";
private footer = "";

Code should as following


private $head = "";
private $body = "";
private $footer = "";

Also remove $ at $this->$title and $this->$style

private function __constructor(){
    $this->title = "";
    $this->style = [];
}




dılo sürücü
  • 3,821
  • 1
  • 26
  • 28