getParamString.php
Table of Contents
Functions
- getParamString() : string|null
- Retrieves a parameter from the HTTP request and ensures it is a string.
Functions
getParamString()
Retrieves a parameter from the HTTP request and ensures it is a string.
getParamString(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $args = [] ][, string|null $defaultValue = null ][, string $strategy = HttpParamStrategy::BOTH ][, bool $throwable = false ]) : string|null
This helper calls getParam() and converts the returned value to a string if set.
- If the value is
nullor missing, the$defaultValueis returned. - If
$throwableis true, a NotFoundException may be thrown bygetParam().
Parameters
- $request : ServerRequestInterface|null
-
The PSR-7 server request instance.
- $name : string
-
The parameter name or dot-notated path.
- $args : array<string|int, mixed> = []
-
Optional default values passed to
getParam(). - $defaultValue : string|null = null
-
Value returned if the parameter is missing or null. Default is null.
- $strategy : string = HttpParamStrategy::BOTH
-
Which source to search:
HttpParamStrategy::BOTH|QUERY|BODY. Default is BOTH. - $throwable : bool = false
-
Whether to throw a
NotFoundExceptionif parameter is missing. Default false.
Tags
Return values
string|null —The parameter value cast to string if present, otherwise $defaultValue or null.