-
Notifications
You must be signed in to change notification settings - Fork 0
PHP Application Guide
Guilherme Barile edited this page Feb 27, 2014
·
2 revisions
On a PHP Application, controllers handle data and rendering templates on the server.
app/
templates/
_init.php
index.php
<?php
include_once '../objectiveweb/_init.php';
route('GET /?', 'handle_get');
route('POST /?', 'handle_post');
function handle_get() {
assign('posts', get('guestbook'));
render('index');
}
function handle_post() {
$data = parse_post_body();
// perform validation
post('guestbook', $data);
redirect('index.php');
}
Assigns a template variable which can be printed using {$var} on the template file.
Just like assign but assigns all variables on the provided associative array of key/value pairs.