HttpUtility

HTTP Utility class

Table of Contents

Constants

HTTP_STATUS_100  = 'HTTP/1.1 100 Continue'
HTTP_STATUS_101  = 'HTTP/1.1 101 Switching Protocols'
HTTP_STATUS_102  = 'HTTP/1.1 102 Processing'
HTTP_STATUS_103  = 'HTTP/1.1 103 Early Hints'
HTTP_STATUS_200  = 'HTTP/1.1 200 OK'
HTTP_STATUS_201  = 'HTTP/1.1 201 Created'
HTTP_STATUS_202  = 'HTTP/1.1 202 Accepted'
HTTP_STATUS_203  = 'HTTP/1.1 203 Non-Authoritative Information'
HTTP_STATUS_204  = 'HTTP/1.1 204 No Content'
HTTP_STATUS_205  = 'HTTP/1.1 205 Reset Content'
HTTP_STATUS_206  = 'HTTP/1.1 206 Partial Content'
HTTP_STATUS_207  = 'HTTP/1.1 207 Multi-status'
HTTP_STATUS_208  = 'HTTP/1.1 208 Already Reported'
HTTP_STATUS_226  = 'HTTP/1.1 226 IM Used'
HTTP_STATUS_300  = 'HTTP/1.1 300 Multiple Choices'
HTTP_STATUS_301  = 'HTTP/1.1 301 Moved Permanently'
HTTP_STATUS_302  = 'HTTP/1.1 302 Found'
HTTP_STATUS_303  = 'HTTP/1.1 303 See Other'
HTTP_STATUS_304  = 'HTTP/1.1 304 Not Modified'
HTTP_STATUS_305  = 'HTTP/1.1 305 Use Proxy'
HTTP_STATUS_306  = 'HTTP/1.1 306 Switch Proxy'
HTTP_STATUS_307  = 'HTTP/1.1 307 Temporary Redirect'
HTTP_STATUS_308  = 'HTTP/1.1 308 Permanent Redirect'
HTTP_STATUS_400  = 'HTTP/1.1 400 Bad Request'
HTTP_STATUS_401  = 'HTTP/1.1 401 Unauthorized'
HTTP_STATUS_402  = 'HTTP/1.1 402 Payment Required'
HTTP_STATUS_403  = 'HTTP/1.1 403 Forbidden'
HTTP_STATUS_404  = 'HTTP/1.1 404 Not Found'
HTTP_STATUS_405  = 'HTTP/1.1 405 Method Not Allowed'
HTTP_STATUS_406  = 'HTTP/1.1 406 Not Acceptable'
HTTP_STATUS_407  = 'HTTP/1.1 407 Proxy Authentication Required'
HTTP_STATUS_408  = 'HTTP/1.1 408 Request Timeout'
HTTP_STATUS_409  = 'HTTP/1.1 409 Conflict'
HTTP_STATUS_410  = 'HTTP/1.1 410 Gone'
HTTP_STATUS_411  = 'HTTP/1.1 411 Length Required'
HTTP_STATUS_412  = 'HTTP/1.1 412 Precondition Failed'
HTTP_STATUS_413  = 'HTTP/1.1 413 Request Entity Too Large'
HTTP_STATUS_414  = 'HTTP/1.1 414 URI Too Long'
HTTP_STATUS_415  = 'HTTP/1.1 415 Unsupported Media Type'
HTTP_STATUS_416  = 'HTTP/1.1 416 Requested range not satisfiable'
HTTP_STATUS_417  = 'HTTP/1.1 417 Expectation Failed'
HTTP_STATUS_418  = 'HTTP/1.1 418 I\'m a teapot'
HTTP_STATUS_422  = 'HTTP/1.1 422 Unprocessable Entity'
HTTP_STATUS_423  = 'HTTP/1.1 423 Locked'
HTTP_STATUS_424  = 'HTTP/1.1 424 Failed Dependency'
HTTP_STATUS_425  = 'HTTP/1.1 425 Unordered Collection'
HTTP_STATUS_426  = 'HTTP/1.1 426 Upgrade Required'
HTTP_STATUS_428  = 'HTTP/1.1 428 Precondition Required'
HTTP_STATUS_429  = 'HTTP/1.1 429 Too Many Requests'
HTTP_STATUS_431  = 'HTTP/1.1 431 Request Header Fields Too Large'
HTTP_STATUS_451  = 'HTTP/1.1 451 Unavailable For Legal Reasons'
HTTP_STATUS_500  = 'HTTP/1.1 500 Internal Server Error'
HTTP_STATUS_501  = 'HTTP/1.1 501 Not Implemented'
HTTP_STATUS_502  = 'HTTP/1.1 502 Bad Gateway'
HTTP_STATUS_503  = 'HTTP/1.1 503 Service Unavailable'
HTTP_STATUS_504  = 'HTTP/1.1 504 Gateway Time-out'
HTTP_STATUS_505  = 'HTTP/1.1 505 Version not Supported'
HTTP_STATUS_506  = 'HTTP/1.1 506 Variant Also Negotiates'
HTTP_STATUS_507  = 'HTTP/1.1 507 Insufficient Storage'
HTTP_STATUS_508  = 'HTTP/1.1 508 Loop Detected'
HTTP_STATUS_509  = 'HTTP/1.1 509 Bandwidth Limit Exceeded'
HTTP_STATUS_511  = 'HTTP/1.1 511 Network Authentication Required'
SCHEME_HTTP  = 1
SCHEME_HTTPS  = 2

Methods

buildQueryString()  : string
Implodes a multidimensional array of query parameters to a string of GET parameters (eg. param[key][key2]=value2&param[key][key3]=value3) and properly encodes parameter names as well as values. Spaces are encoded as %20
buildUrl()  : string
Builds a URL string from an array with the URL parts, as e.g. output by parse_url().
redirect()  : mixed
Sends a redirect header response and exits. Additionally the URL is checked and if needed corrected to match the format required for a Location redirect header. By default the HTTP status code sent is a 'HTTP/1.1 303 See Other'.
setResponseCode()  : mixed
Set a specific response code like 404.
setResponseCodeAndExit()  : mixed
Set a specific response code and exit script execution.

Constants

HTTP_STATUS_100

public mixed HTTP_STATUS_100 = 'HTTP/1.1 100 Continue'

HTTP_STATUS_101

public mixed HTTP_STATUS_101 = 'HTTP/1.1 101 Switching Protocols'

HTTP_STATUS_102

public mixed HTTP_STATUS_102 = 'HTTP/1.1 102 Processing'

HTTP_STATUS_103

public mixed HTTP_STATUS_103 = 'HTTP/1.1 103 Early Hints'

HTTP_STATUS_200

public mixed HTTP_STATUS_200 = 'HTTP/1.1 200 OK'

HTTP_STATUS_201

public mixed HTTP_STATUS_201 = 'HTTP/1.1 201 Created'

HTTP_STATUS_202

public mixed HTTP_STATUS_202 = 'HTTP/1.1 202 Accepted'

HTTP_STATUS_203

public mixed HTTP_STATUS_203 = 'HTTP/1.1 203 Non-Authoritative Information'

HTTP_STATUS_204

public mixed HTTP_STATUS_204 = 'HTTP/1.1 204 No Content'

HTTP_STATUS_205

public mixed HTTP_STATUS_205 = 'HTTP/1.1 205 Reset Content'

HTTP_STATUS_206

public mixed HTTP_STATUS_206 = 'HTTP/1.1 206 Partial Content'

HTTP_STATUS_207

public mixed HTTP_STATUS_207 = 'HTTP/1.1 207 Multi-status'

HTTP_STATUS_208

public mixed HTTP_STATUS_208 = 'HTTP/1.1 208 Already Reported'

HTTP_STATUS_226

public mixed HTTP_STATUS_226 = 'HTTP/1.1 226 IM Used'

HTTP_STATUS_300

public mixed HTTP_STATUS_300 = 'HTTP/1.1 300 Multiple Choices'

HTTP_STATUS_301

public mixed HTTP_STATUS_301 = 'HTTP/1.1 301 Moved Permanently'

HTTP_STATUS_302

public mixed HTTP_STATUS_302 = 'HTTP/1.1 302 Found'

HTTP_STATUS_303

public mixed HTTP_STATUS_303 = 'HTTP/1.1 303 See Other'

HTTP_STATUS_304

public mixed HTTP_STATUS_304 = 'HTTP/1.1 304 Not Modified'

HTTP_STATUS_305

public mixed HTTP_STATUS_305 = 'HTTP/1.1 305 Use Proxy'

HTTP_STATUS_306

public mixed HTTP_STATUS_306 = 'HTTP/1.1 306 Switch Proxy'

HTTP_STATUS_307

public mixed HTTP_STATUS_307 = 'HTTP/1.1 307 Temporary Redirect'

HTTP_STATUS_308

public mixed HTTP_STATUS_308 = 'HTTP/1.1 308 Permanent Redirect'

HTTP_STATUS_400

public mixed HTTP_STATUS_400 = 'HTTP/1.1 400 Bad Request'

HTTP_STATUS_401

public mixed HTTP_STATUS_401 = 'HTTP/1.1 401 Unauthorized'

HTTP_STATUS_402

public mixed HTTP_STATUS_402 = 'HTTP/1.1 402 Payment Required'

HTTP_STATUS_403

public mixed HTTP_STATUS_403 = 'HTTP/1.1 403 Forbidden'

HTTP_STATUS_404

public mixed HTTP_STATUS_404 = 'HTTP/1.1 404 Not Found'

HTTP_STATUS_405

public mixed HTTP_STATUS_405 = 'HTTP/1.1 405 Method Not Allowed'

HTTP_STATUS_406

public mixed HTTP_STATUS_406 = 'HTTP/1.1 406 Not Acceptable'

HTTP_STATUS_407

public mixed HTTP_STATUS_407 = 'HTTP/1.1 407 Proxy Authentication Required'

HTTP_STATUS_408

public mixed HTTP_STATUS_408 = 'HTTP/1.1 408 Request Timeout'

HTTP_STATUS_409

public mixed HTTP_STATUS_409 = 'HTTP/1.1 409 Conflict'

HTTP_STATUS_410

public mixed HTTP_STATUS_410 = 'HTTP/1.1 410 Gone'

HTTP_STATUS_411

public mixed HTTP_STATUS_411 = 'HTTP/1.1 411 Length Required'

HTTP_STATUS_412

public mixed HTTP_STATUS_412 = 'HTTP/1.1 412 Precondition Failed'

HTTP_STATUS_413

public mixed HTTP_STATUS_413 = 'HTTP/1.1 413 Request Entity Too Large'

HTTP_STATUS_414

public mixed HTTP_STATUS_414 = 'HTTP/1.1 414 URI Too Long'

HTTP_STATUS_415

public mixed HTTP_STATUS_415 = 'HTTP/1.1 415 Unsupported Media Type'

HTTP_STATUS_416

public mixed HTTP_STATUS_416 = 'HTTP/1.1 416 Requested range not satisfiable'

HTTP_STATUS_417

public mixed HTTP_STATUS_417 = 'HTTP/1.1 417 Expectation Failed'

HTTP_STATUS_418

public mixed HTTP_STATUS_418 = 'HTTP/1.1 418 I\'m a teapot'

HTTP_STATUS_422

public mixed HTTP_STATUS_422 = 'HTTP/1.1 422 Unprocessable Entity'

HTTP_STATUS_423

public mixed HTTP_STATUS_423 = 'HTTP/1.1 423 Locked'

HTTP_STATUS_424

public mixed HTTP_STATUS_424 = 'HTTP/1.1 424 Failed Dependency'

HTTP_STATUS_425

public mixed HTTP_STATUS_425 = 'HTTP/1.1 425 Unordered Collection'

HTTP_STATUS_426

public mixed HTTP_STATUS_426 = 'HTTP/1.1 426 Upgrade Required'

HTTP_STATUS_428

public mixed HTTP_STATUS_428 = 'HTTP/1.1 428 Precondition Required'

HTTP_STATUS_429

public mixed HTTP_STATUS_429 = 'HTTP/1.1 429 Too Many Requests'

HTTP_STATUS_431

public mixed HTTP_STATUS_431 = 'HTTP/1.1 431 Request Header Fields Too Large'

HTTP_STATUS_451

public mixed HTTP_STATUS_451 = 'HTTP/1.1 451 Unavailable For Legal Reasons'

HTTP_STATUS_500

public mixed HTTP_STATUS_500 = 'HTTP/1.1 500 Internal Server Error'

HTTP_STATUS_501

public mixed HTTP_STATUS_501 = 'HTTP/1.1 501 Not Implemented'

HTTP_STATUS_502

public mixed HTTP_STATUS_502 = 'HTTP/1.1 502 Bad Gateway'

HTTP_STATUS_503

public mixed HTTP_STATUS_503 = 'HTTP/1.1 503 Service Unavailable'

HTTP_STATUS_504

public mixed HTTP_STATUS_504 = 'HTTP/1.1 504 Gateway Time-out'

HTTP_STATUS_505

public mixed HTTP_STATUS_505 = 'HTTP/1.1 505 Version not Supported'

HTTP_STATUS_506

public mixed HTTP_STATUS_506 = 'HTTP/1.1 506 Variant Also Negotiates'

HTTP_STATUS_507

public mixed HTTP_STATUS_507 = 'HTTP/1.1 507 Insufficient Storage'

HTTP_STATUS_508

public mixed HTTP_STATUS_508 = 'HTTP/1.1 508 Loop Detected'

HTTP_STATUS_509

public mixed HTTP_STATUS_509 = 'HTTP/1.1 509 Bandwidth Limit Exceeded'

HTTP_STATUS_511

public mixed HTTP_STATUS_511 = 'HTTP/1.1 511 Network Authentication Required'

Methods

buildQueryString()

Implodes a multidimensional array of query parameters to a string of GET parameters (eg. param[key][key2]=value2&param[key][key3]=value3) and properly encodes parameter names as well as values. Spaces are encoded as %20

public static buildQueryString(array<string|int, mixed> $parameters[, string $prependCharacter = '' ][, bool $skipEmptyParameters = false ]) : string
Parameters
$parameters : array<string|int, mixed>

The (multidimensional) array of query parameters with values

$prependCharacter : string = ''

If the created query string is not empty, prepend this character "?" or "&" else no prepend

$skipEmptyParameters : bool = false

If true, empty parameters (blank string, empty array, null) are removed.

Tags
see
explodeUrl2Array()
Return values
string

Imploded result, for example param[key][key2]=value2&param[key][key3]=value3

buildUrl()

Builds a URL string from an array with the URL parts, as e.g. output by parse_url().

public static buildUrl(array<string|int, mixed> $urlParts) : string
Parameters
$urlParts : array<string|int, mixed>
Tags
see
http://www.php.net/parse_url
Return values
string

redirect()

Sends a redirect header response and exits. Additionally the URL is checked and if needed corrected to match the format required for a Location redirect header. By default the HTTP status code sent is a 'HTTP/1.1 303 See Other'.

public static redirect(string $url[, string $httpStatus = self::HTTP_STATUS_303 ]) : mixed
Deprecated

since v11, will be removed in v12.

Parameters
$url : string

The target URL to redirect to

$httpStatus : string = self::HTTP_STATUS_303

An optional HTTP status header. Default is 'HTTP/1.1 303 See Other'

setResponseCode()

Set a specific response code like 404.

public static setResponseCode([string $httpStatus = self::HTTP_STATUS_303 ]) : mixed
Deprecated

since v11, will be removed in v12.

Parameters
$httpStatus : string = self::HTTP_STATUS_303

One of the HTTP_STATUS_* class class constants, default to self::HTTP_STATUS_303

setResponseCodeAndExit()

Set a specific response code and exit script execution.

public static setResponseCodeAndExit([string $httpStatus = self::HTTP_STATUS_303 ]) : mixed
Deprecated

since v11, will be removed in v12.

Parameters
$httpStatus : string = self::HTTP_STATUS_303

One of the HTTP_STATUS_* class class constants, default to self::HTTP_STATUS_303


        
On this page

Search results