In order for us to figure out what route was passed in a request, we'll need to add the following two functions to the lib/bones.php
file underneath the closing bracket of the get_instance()
function:
/Library/Webserver/Documents/verge/lib/bones.php
public static function get_instance() {
if (!isset(self::$instance)) {
self::$instance = new Bones();
}
return self::$instance;
}
public function __construct() {
$this->route = $this->get_route();
}
protected function get_route() {
parse_str($_SERVER['QUERY_STRING'], $route);
if ($route) {
return '/' . $route['request'];
} else {
return '/';
}
}
In this piece of code, we added a function called __construct()
, which is a function that is automatically called each time a class is created. Our __construct()
function then calls another function named get_route()
, which will grab the route (if there is one) from our request query string and return...