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 — retrieving the HTTP method used in a request

We have done most of the heavy lifting required to support, capture, and handle HTTP requests. We just need to plug in a few extra lines of code.

  1. Let's add a variable to our Bones class, called $method, after our $route variable. This variable will store the HTTP method that was performed on each request:
    class Bones {
    private static $instance;
    public static $route_found = false;
    public $route = '';
    public $method = '';
    
    public $content = '';
    
  2. In order for us to get the method on each request, we will need to add a line of code in our __construct() function, named get_route(), and save the value of the result in our instances variable $method. This means that when Bones is created on ...

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