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 — creating the register function to match routes

The register function will be one of the most important functions in the Bones class down the road, but we'll just get started by adding the following code at the end of our lib/bones.php file:

/Library/Webserver/Documents/verge/lib/bones.php

public static function register($route, $callback) {
$bones = static::get_instance();
if ($route == $bones->route && !static::$route_found) {
static::$route_found = true;
echo $callback($bones);
} else {
return false;
}
}

What just happened?

We started by creating a public static function called register. This function has two parameters: $route and $callback. $route contains the route that we are attempting to match against the actual route, ...

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