The MVC Pattern in PHP –start a bare bone sample–continue

we start to write the some class included  very basic PHP architecture on the MVC pattern.

here is your MVC pattern sources code:

<?php
class Model
{
    public $string;
    public function __construct()
    {
        $this -> string = “MVC + PHP = Awosome!”;    
    }
}
?>
<?php
class View
{
    private $model;
    private $controller;
    
    public function __construct($constroller,$model)
    {
        $this ->controller = $controller;
        $this ->model = $model;    
    }
    
    public function output()
    {
        return “<p>”. $this->model->string .”</p>”;
    }
}
?>
<?php
class Controller
{
    private $model;
    
    public function __construct($model)
    {
        $this->model = $model;    
    }
}
?>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s