/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * Access the HTTP Request */ /** additional HTTP headers not prefixed with HTTP_ in $_SERVER superglobal */ /** * Construtor * Retrieve HTTP Body * @param Array Additional Headers to retrieve */ $this->retrieve_headers($add_headers); } /** * Retrieve the HTTP request headers from the $_SERVER superglobal * @param Array Additional Headers to retrieve */ function retrieve_headers($add_headers = false) { if ($add_headers) { } $this->method = $_SERVER['HTTP_METHOD']; } else { } foreach($_SERVER as $i=>$val) { $this->headers[$name] = $val; } } } /** * Retrieve HTTP Method */ function method() { return $this->method; } /** * Retrieve HTTP Body */ function body() { return $this->body; } /** * Retrieve an HTTP Header * @param string Case-Insensitive HTTP Header Name (eg: "User-Agent") */ } /** * Retrieve all HTTP Headers * @return array HTTP Headers */ function headers() { return $this->headers; } /** * Return Raw HTTP Request (note: This is incomplete) * @param bool ReBuild the Raw HTTP Request */ function raw($refresh = false) { return $this->raw; // return cached } $headers = $this->headers(); $this->raw = "{$this->method} "; foreach($headers as $i=>$header) { $this->raw .= "$i: $header "; } $this->raw .= " {$http_request->body}"; return $this->raw; } } ?>