Tag Archives: MVC

Create a model Post

Create a model file named post.php under model direction. and mode are class, so create a class named post, and all model class extends the appModel class.

so my model it looks like this

class Post extends AppModel {
    var $name = “Post”;//this don’t need it ,but this is good for php4
}

that is all we need for model

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;    
    }
}
?>