Código:
class Model:
def get_post(self, id):
# Would query database, perhaps
return {"title": "A test", "body": "An example.."}
class Controller:
def __init__(self):
self.model = Model()
self.view = View()
def main(self):
post = self.model.get_post(1)
self.view.display(post)
class View:
def display(self, item):
print "<h1>%(title)s</h1>\n%(body)s" % item
c = Controller()
c.main()
Código PHP:
<?php
public $controlador='home',$metodo='index',$argumentos=[1,2,3];
class Model{
public function get_post($self,$id){
return "Titulo: $titulo, Body: $body";
}
}
class Controller{
public function __construct__($self){
self::Model($modelo);
self::View($vista);
}
public function ($main){
$post=self.model.get_post(1);
self.view.display(post);
}
}
class View{
public function display($self,$item){
print "<h1>$titulo</h1><div>$body</div>";
}
}
?>