REQUESTMETHOD.php
- The class implements receiving requests from clients and also sending the passed json data back to the clients in dictionary format.
Collaboration
- Refer to Python REQUESTMETHOD.py (class REQUESTMETHOD)
Constructor
- Parameters
- $getServer : passing global $_SERVER
public function __construct($getServer)
API
- Handling GET/POST/PUT/DELETE requests automatically at beginning constructor, and all methods are private functions
public function __construct($getServer) {
$this -> method = $getServer['REQUEST_METHOD'];
switch($this -> method) {
default:
case "GET":
$this -> GET();
break;
case "POST":
$this -> POST();
break;
case "PUT":
case "DELETE":
$this -> PUTOrDelete();
break;
}
}
- Sending GET/POST/PUT/DELETE responses to client
public function response($format)
Example
- Construct a object and also wait requests to response client with the json data
$obj = new REQUESTMETHOD($_SERVER);
echo $obj->response("json");