What is an example of MVC in PHP?

Posted by waiwai933 on Stack Overflow See other posts from Stack Overflow or by waiwai933
Published on 2010-05-09T00:49:35Z Indexed on 2010/05/09 0:58 UTC
Read the original article Hit count: 235

Filed under:
|

I'm trying to understand the MVC pattern. Here's what I think MV is:

Model:

<?php 
if($a == 2){
    $variable = 'two';
}
else{
    $variable = 'not two';
}
$this->output->addContent($variable);
$this->output->displayContent();
?> 

View:

<?php 

class output{

    private $content;

    public function addContent($var){
        $this->content =  'The variable is '.$var;
    }

    public function displayContent(){
        include 'header.php';
        echo $content;
        include 'footer.php';
    }

}
?>

Is this right? If so, what is the controller?

© Stack Overflow or respective owner

Related posts about php

Related posts about mvc