Created
March 12, 2011 17:37
-
-
Save uppfinnarjohnny/867392 to your computer and use it in GitHub Desktop.
Tok-simpel MVC-struktur
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('posts_model.php'); | |
$posts = get_posts(); | |
include('view.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_posts() { | |
$posts = array( | |
(object) array( | |
'title' => 'En titel', | |
'body' => 'Här är då brödtexten' | |
), | |
(object) array( | |
'title' => 'En till titel', | |
'body' => 'Och en till brödtext' | |
) | |
); | |
return $posts; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
<title>MVC-exempel</title> | |
</head> | |
<body> | |
<h1>Ett MVC-exempel</h1> | |
<?php foreach($posts as $post): ?> | |
<div class="post"> | |
<h2><?php echo $post->title; ?></h2> | |
<?php echo $post->body; ?> | |
</div> | |
<?php endforeach; ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment