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 Bones to store variables and the content path

We need to be able to set and receive variables to our views from index.php. So, let's add that support into Bones.

  1. Let's define a public array called $vars that will allow us to store variables from our routes in index.php and a string called $content that will house the path to the view that will be loaded into our layout. We'll start by adding two variables just inside our lib/bones.php class:
    class Bones {
    public $route = '';
    public $content = '';
    public $vars = array();
    
    public function __construct() {
    ...
    }
    
  2. In order for us to set variables from our index.php file, we'll create a simple function called set that will allow us to pass an index and a value for a variable ...

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