phpEZ v0.1.3

HTTP : string
in package

HTTP request method enum.

Represents standard HTTP verbs supported by the PHPEz API framework. Provides utilities to get the current request method and validate method types.

Tags
subpackage

http

see
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods

Table of Contents

Cases

DELETE  = 'DELETE'
GET  = 'GET'
POST  = 'POST'
PUT  = 'PUT'
REPORT  = 'REPORT'

Methods

is()  : bool
Check if this HTTP method matches a given method or the current request method.
method()  : static
Get the HTTP method of the current request.
remote_addr()  : string
Get the remote client IP address, accounting for proxies.

Cases

Methods

is()

Check if this HTTP method matches a given method or the current request method.

public is([string|null $meth = null ]) : bool

Usage:

if (HTTP::POST->is()) { ... }                    // Check if current is POST
if ($method->is(HTTP::GET->value)) { ... }      // Check if $method is GET
Parameters
$meth : string|null = null

Optional HTTP method value to compare against. If null, compares against the current request method.

Return values
bool

True if this method matches the given method or current request.

method()

Get the HTTP method of the current request.

public static method() : static
Tags
throws
never

Relies on $_SERVER['REQUEST_METHOD'] which is always set.

Return values
static

The HTTP method enum case for the current request.

remote_addr()

Get the remote client IP address, accounting for proxies.

public static remote_addr() : string

Checks HTTP headers in order of reliability to determine the actual client IP:

  1. HTTP_CLIENT_IP (from client proxy)
  2. HTTP_X_FORWARDED_FOR (from proxy chain)
  3. REMOTE_ADDR (direct connection)
Tags
throws
HTTPException

If no IP address can be determined.

Return values
string

The client IP address.

On this page

Search results