Leaf PHP

Headers
in package

HTTP Headers --------------------- Response header management made simple with Leaf

Tags
author

Michael Darko

since
2.0.0

Table of Contents

Properties

$httpCode  : int

Methods

accessControl()  : mixed
Quickly set an access control header
all()  : array<string|int, mixed>
Get all headers passed into application
contentHtml()  : void
Set the content-type to html
contentJSON()  : void
Set the content-type to json
contentPlain()  : void
Set the content-type to plain text
contentXml()  : void
Set the content-type to xml
get()  : array<string|int, mixed>|string|null
Return a particular header passed into app
has()  : mixed
Check if a header is present
remove()  : mixed
Remove a header
resetStatus()  : mixed
Force an HTTP code for response using PHP's `http_response_code`
set()  : void
Set a new header
status()  : mixed
Get or Set an HTTP code for response
findHeaders()  : mixed

Properties

$httpCode

protected static int $httpCode = 200

Methods

accessControl()

Quickly set an access control header

public static accessControl(mixed $key[, mixed $value = "" ][, mixed $code = 200 ]) : mixed
Parameters
$key : mixed
$value : mixed = ""
$code : mixed = 200

all()

Get all headers passed into application

public static all([bool $safeOutput = false ]) : array<string|int, mixed>
Parameters
$safeOutput : bool = false

Try to sanitize header data

Return values
array<string|int, mixed>

contentHtml()

Set the content-type to html

public static contentHtml([mixed $code = 200 ]) : void
Parameters
$code : mixed = 200

contentJSON()

Set the content-type to json

public static contentJSON([mixed $code = 200 ]) : void
Parameters
$code : mixed = 200

contentPlain()

Set the content-type to plain text

public static contentPlain([mixed $code = 200 ]) : void
Parameters
$code : mixed = 200

contentXml()

Set the content-type to xml

public static contentXml([mixed $code = 200 ]) : void
Parameters
$code : mixed = 200

get()

Return a particular header passed into app

public static get(array<string|int, mixed>|string $params[, bool $safeOutput = false ]) : array<string|int, mixed>|string|null
Parameters
$params : array<string|int, mixed>|string

The header(s) to return

$safeOutput : bool = false

Try to sanitize header data

Return values
array<string|int, mixed>|string|null

has()

Check if a header is present

public static has(string $header) : mixed
Parameters
$header : string

The header to check

remove()

Remove a header

public static remove(mixed $keys) : mixed
Parameters
$keys : mixed

resetStatus()

Force an HTTP code for response using PHP's `http_response_code`

public static resetStatus([int $httpCode = 200 ]) : mixed
Parameters
$httpCode : int = 200

The response code to set

set()

Set a new header

public static set(mixed $key[, string $value = "" ][, mixed $replace = true ][, int $httpCode = 200 ]) : void
Parameters
$key : mixed
$value : string = ""
$replace : mixed = true
$httpCode : int = 200

status()

Get or Set an HTTP code for response

public static status([int|null $httpCode = null ]) : mixed
Parameters
$httpCode : int|null = null

The current response code.

findHeaders()

protected static findHeaders() : mixed

        
On this page

Search results