个人觉得还可以的php代码,老大不买账

function pageFactory($path,$layout)

{

    $factorys = Array ("template/1.html"=>TemplatePage1);

    return new $factorys[$layout]($path,$layout);

}



class Page

{

    public $path = null; 

    public $layout = "";

    public $data = Array();

    

    public static function load($path)

    {

        

    }

    

    public function Page($path,$layout)

    {

        echo "page...";

        $this->path = $path;

        $this->layout = $layout;

    }

    

    public function show()

    {

        $fileHandler = fopen($this->layout, r);

        $html = fread($fileHandler, 1024);

        fclose($fileHandler);

        return $html;

    }

    

    public function save($data){}

}



class TemplatePage1 extends Page

{

    public function save($data)

    {

        $fileHandler = fopen($this->path,w);

        fwrite($fileHandler,json_encode(

                Array(

                    "layout" => $this->layout,

                    "data" => Array("title" => $data["title"],

                                    "content" => $data["content"])

                    )));

        fclose($fileHandler);

    }

}

 

你可能感兴趣的:(PHP)