-
Book Overview & Buying
-
Table Of Contents
CouchDB and PHP Web Development Beginner's Guide
By :
Let's start building out the Bones class by adding the following code to the lib/bones.php file inside our working directory:
/Library/Webserver/Documents/verge/lib/bones.php
<?php
class Bones {
private static $instance;
public static $route_found = false;
public $route = '';
public static function get_instance() {
if (!isset(self::$instance)) {
self::$instance = new Bones();
}
return self::$instance;
}
We just created our Bones class, added a few private and public variables, and a strange function called get_instance(). The private static variable $instance, mixed with the function get_instance(), forms something that is called The Singleton Pattern.
The Singleton Pattern allows our Bones class to not just be a simple class, but also to be one object. This means that each time we call our Bones class, we are accessing a single existing object. But if the object does not exist, it will create a new one...
Change the font size
Change margin width
Change background colour