我创建了一个用于生成html网页的类。 我现在遇到错误。 我找不到我做错的地方,也许我有错别字,有人可以帮助我吗? 我将不胜感激。 这是我未声明或未添加的内容。
/*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";
}
}
?>
答案 0 :(得分:0)
在前面添加$符号,但缺少$
private head = "";
private body = "";
private footer = "";
代码应如下
private $head = "";
private $body = "";
private $footer = "";
还要删除$ this-> $ title和$ this-> $ style
的$private function __constructor(){
$this->title = "";
$this->style = [];
}