The RequestHandler class is intended to easily access the REQUEST content. Therefore, the component uses the $_REQUEST, $_GET, or the $_POST array.

The application of the static class looks as follows:

PHP code
use APF\tools\request\RequestHandler; // get a single request value $value = RequestHandler::getValue('foo', 'bar'); $value = RequestHandler::getValue('foo', 'bar', RequestHandler::USE_GET_PARAMS); $value = RequestHandler::getValue('foo', 'bar', RequestHandler::USE_POST_PARAMS); // define a param array with default values $params = array('foo' => 'bar', 'baz'); $values = RequestHandler::getValues($params); $values = RequestHandler::getValues($params, RequestHandler::USE_GET_PARAMS); $values = RequestHandler::getValues($params, RequestHandler::USE_POST_PARAMS);

The $value variable does contain the value of the request param foo. If the param is not contained in the URL, the value is bar. The array $values contains the value of the param foo within one offset, the offset baz includes the corresponding request value. In case the foo param is not found in the request, the default value is set to bar. If the baz param is not found, null is returned in that offset. Further details can be taken from the API documentation.

Nutzen Sie die Konstanten RequestHandler::USE_GET_PARAMS, RequestHandler::USE_POST_PARAMS oder RequestHandler::USE_REQUEST_PARAMS (Standard) um die Quelle der gewünschten Daten zu wählen. Möchten Sie Daten lediglich im Fall einer HTTP-GET- oder HTTP-POST-Anfrage erhalten, so bietet sich die Übergabe des dritten, optionalen Parameters an. In allen anderen Fällen werden die Daten aus dem $_REQUEST-Array ausgelesen.


Do you want to add a comment to the article above, or do you want to post additional hints? So please click here. Comments already posted can be found below.
There are no comments belonging to this article.

In order to provide a state-of-the-art web experience and to continuously improve our services we are using cookies. By using this web page you agree to the use of cookies. For more information, please refer to our Privacy policy.