The requestCheck function in UserSpice is a custom function used to check and retrieve request variables from $_GET and $_POST superglobal arrays. It ensures that the expected variables are present in the request and returns them as an array. If any expec
Location
users/helpers/us_helpers.php
Parameters
#
Parameter
Data Type
Required
Description
1
$expectedAr
array
Yes
An array of expected variable names.
Returns
Data Type
Description of Returned Data
array
The function returns an associative array containing the request variables if all expected variables are present.
In the example above, the requestCheck function is called with the $expectedVariables array as the argument, which lists the expected variable names. The function checks for the presence of the variables in the request, combining $_GET and $_POST superglobal arrays. If any expected variables are missing, the returnError function is called to generate an error response and halt the script execution.
If all expected variables are present, the function returns an associative array containing the request variables. You can then access specific variables by their respective keys in the array.
Note that the returnError function is typically called within requestCheck to handle error scenarios and provide a standardized error response format.