Class

Symfony\Component\HttpFoundation\ServerBag

class ServerBag extends ParameterBag

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

Methods

__construct(array $parameters = array())

Constructor.

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 $path, mixed $default = null, boolean $deep = false)

Returns a parameter by name.

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

Sets a parameter by name.

from ParameterBag
Boolean has(string $key)

Returns true if the parameter is defined.

from ParameterBag
remove(string $key)

Removes a parameter.

from ParameterBag
string getAlpha(string $key, mixed $default = '', boolean $deep = false)

Returns the alphabetic characters of the parameter value.

from ParameterBag
string getAlnum(string $key, mixed $default = '', boolean $deep = false)

Returns the alphabetic characters and digits of the parameter value.

from ParameterBag
string getDigits(string $key, mixed $default = '', boolean $deep = false)

Returns the digits of the parameter value.

from ParameterBag
integer getInt(string $key, mixed $default, boolean $deep = false)

Returns the parameter value converted to integer.

from ParameterBag
mixed filter(string $key, mixed $default = null, boolean $deep = false, integer $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

in ParameterBag at line 37
public __construct(array $parameters = array())

Constructor.

Parameters

array $parameters An array of parameters

in ParameterBag at line 49
public array all()

Returns the parameters.

Return Value

array An array of parameters

in ParameterBag at line 61
public array keys()

Returns the parameter keys.

Return Value

array An array of parameter keys

in ParameterBag at line 73
public replace(array $parameters = array())

Replaces the current parameters by a new set.

Parameters

array $parameters An array of parameters

in ParameterBag at line 85
public add(array $parameters = array())

Adds parameters.

Parameters

array $parameters An array of parameters

in ParameterBag at line 103
public mixed get(string $path, mixed $default = null, boolean $deep = false)

Returns a parameter by name.

Parameters

string $path The key
mixed $default The default value if the parameter key does not exist
boolean $deep If true, a path like foo[bar] will find deeper items

Return Value

mixed

Exceptions

InvalidArgumentException

in ParameterBag at line 160
public set(string $key, mixed $value)

Sets a parameter by name.

Parameters

string $key The key
mixed $value The value

in ParameterBag at line 174
public Boolean has(string $key)

Returns true if the parameter is defined.

Parameters

string $key The key

Return Value

Boolean true if the parameter exists, false otherwise

in ParameterBag at line 186
public remove(string $key)

Removes a parameter.

Parameters

string $key The key

in ParameterBag at line 202
public string getAlpha(string $key, mixed $default = '', boolean $deep = false)

Returns the alphabetic characters of the parameter value.

Parameters

string $key The parameter key
mixed $default The default value if the parameter key does not exist
boolean $deep If true, a path like foo[bar] will find deeper items

Return Value

string The filtered value

in ParameterBag at line 218
public string getAlnum(string $key, mixed $default = '', boolean $deep = false)

Returns the alphabetic characters and digits of the parameter value.

Parameters

string $key The parameter key
mixed $default The default value if the parameter key does not exist
boolean $deep If true, a path like foo[bar] will find deeper items

Return Value

string The filtered value

in ParameterBag at line 234
public string getDigits(string $key, mixed $default = '', boolean $deep = false)

Returns the digits of the parameter value.

Parameters

string $key The parameter key
mixed $default The default value if the parameter key does not exist
boolean $deep If true, a path like foo[bar] will find deeper items

Return Value

string The filtered value

in ParameterBag at line 251
public integer getInt(string $key, mixed $default, boolean $deep = false)

Returns the parameter value converted to integer.

Parameters

string $key The parameter key
mixed $default The default value if the parameter key does not exist
boolean $deep If true, a path like foo[bar] will find deeper items

Return Value

integer The filtered value

in ParameterBag at line 269
public mixed filter(string $key, mixed $default = null, boolean $deep = false, integer $filter = FILTER_DEFAULT, mixed $options = array())

Filter key.

Parameters

string $key Key.
mixed $default Default = null.
boolean $deep Default = false.
integer $filter FILTER_* constant.
mixed $options Filter options.

Return Value

mixed

See also

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

in ParameterBag at line 291
public ArrayIterator getIterator()

Returns an iterator for parameters.

Return Value

ArrayIterator An \ArrayIterator instance

in ParameterBag at line 301
public int count()

Returns the number of parameters.

Return Value

int The number of parameters

at line 28
public array getHeaders()

Gets the HTTP headers.

Return Value

array