Use this function to get request parameter values. **_NEVER use $_GET and $_POST directly._**
If the variable cannot be found, and a default value was not provided, an exception is raised.
_See {@link sanitizeInputValues()} to learn more about sanitization._
public static getRequestVar ( string $varName, string | null $varDefault = null, string | null $varType = null, array | null $requestArrayToUse = null ) : mixed | ||
$varName | string | Name of the request parameter to get. By default, we look in `$_GET[$varName]` and `$_POST[$varName]` for the value. |
$varDefault | string | null | The value to return if the request parameter cannot be found or has an empty value. |
$varType | string | null | Expected type of the request variable. This parameters value must be one of the following: `'array'`, `'int'`, `'integer'`, `'string'`, `'json'`. If `'json'`, the string value will be `json_decode`-d and then sanitized. |
$requestArrayToUse | array | null | The array to use instead of `$_GET` and `$_POST`. |
return | mixed | The sanitized request parameter. |