O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — allowing our application to display a view by calling it in index.php

We'll start by creating a public function, called render that accepts two arguments. The first is $view, which is the name (or path) of the view you want to display, and the second is $layout, which will define which layout we use to show the view. Layout will also have a default value, so that we can keep things simple, in order to handle the displaying of views. Add the following code to the lib/bones.php file, right after the set function:

public function set($index, $value) {
$this->vars[$index] = $value;
}
public function render($view, $layout = "layout") { $this->content = ROOT. '/views/' . $view . '.php'; foreach ($this->vars as $key => $value) { $$key ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required