W3cubDocs

/Symfony 4.1

ServerBag

class ServerBag extends ParameterBag

ServerBag is a container for HTTP headers from the $_SERVER variable.

Properties

protected $parameters Parameter storage. from ParameterBag

Methods

__construct(array $parameters = array()) from ParameterBag
array all()

Returns the parameters.

from ParameterBag
array keys()

Returns the parameter keys.

from ParameterBag
replace(array $parameters = array())

Replaces the current parameters by a new set.

from ParameterBag
add(array $parameters = array())

Adds parameters.

from ParameterBag
mixed get(string $key, mixed $default = null)

Returns a parameter by name.

from ParameterBag
set(string $key, mixed $value)

Sets a parameter by name.

from ParameterBag
bool has(string $key)

Returns true if the parameter is defined.

from ParameterBag
remove(string $key)

Removes a parameter.

from ParameterBag
string getAlpha(string $key, string $default = '')

Returns the alphabetic characters of the parameter value.

from ParameterBag
string getAlnum(string $key, string $default = '')

Returns the alphabetic characters and digits of the parameter value.

from ParameterBag
string getDigits(string $key, string $default = '')

Returns the digits of the parameter value.

from ParameterBag
int getInt(string $key, int $default = 0)

Returns the parameter value converted to integer.

from ParameterBag
bool getBoolean(string $key, mixed $default = false)

Returns the parameter value converted to boolean.

from ParameterBag
mixed filter(string $key, mixed $default = null, int $filter = FILTER_DEFAULT, mixed $options = array())

Filter key.

from ParameterBag
ArrayIterator getIterator()

Returns an iterator for parameters.

from ParameterBag
int count()

Returns the number of parameters.

from ParameterBag
array getHeaders()

Gets the HTTP headers.

Details

__construct(array $parameters = array())

Parameters

array $parameters An array of parameters

array all()

Returns the parameters.

Return Value

array An array of parameters

array keys()

Returns the parameter keys.

Return Value

array An array of parameter keys

replace(array $parameters = array())

Replaces the current parameters by a new set.

Parameters

array $parameters An array of parameters

add(array $parameters = array())

Adds parameters.

Parameters

array $parameters An array of parameters

mixed get(string $key, mixed $default = null)

Returns a parameter by name.

Parameters

string $key The key
mixed $default The default value if the parameter key does not exist

Return Value

mixed

set(string $key, mixed $value)

Sets a parameter by name.

Parameters

string $key The key
mixed $value The value

bool has(string $key)

Returns true if the parameter is defined.

Parameters

string $key The key

Return Value

bool true if the parameter exists, false otherwise

remove(string $key)

Removes a parameter.

Parameters

string $key The key

string getAlpha(string $key, string $default = '')

Returns the alphabetic characters of the parameter value.

Parameters

string $key The parameter key
string $default The default value if the parameter key does not exist

Return Value

string The filtered value

string getAlnum(string $key, string $default = '')

Returns the alphabetic characters and digits of the parameter value.

Parameters

string $key The parameter key
string $default The default value if the parameter key does not exist

Return Value

string The filtered value

string getDigits(string $key, string $default = '')

Returns the digits of the parameter value.

Parameters

string $key The parameter key
string $default The default value if the parameter key does not exist

Return Value

string The filtered value

int getInt(string $key, int $default = 0)

Returns the parameter value converted to integer.

Parameters

string $key The parameter key
int $default The default value if the parameter key does not exist

Return Value

int The filtered value

bool getBoolean(string $key, mixed $default = false)

Returns the parameter value converted to boolean.

Parameters

string $key The parameter key
mixed $default The default value if the parameter key does not exist

Return Value

bool The filtered value

mixed filter(string $key, mixed $default = null, int $filter = FILTER_DEFAULT, mixed $options = array())

Filter key.

Parameters

string $key Key
mixed $default Default = null
int $filter FILTER_* constant
mixed $options Filter options

Return Value

mixed

See also

http://php.net/manual/en/function.filter-var.php

ArrayIterator getIterator()

Returns an iterator for parameters.

Return Value

ArrayIterator An \ArrayIterator instance

int count()

Returns the number of parameters.

Return Value

int The number of parameters

array getHeaders()

Gets the HTTP headers.

Return Value

array

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/HttpFoundation/ServerBag.html