Mecha CMS

Mecha CMS blog and documentation.

Class Request

Updated: Sunday, 07 August 2016

Page request.

Check for POST Request

if(Request::method('post')) {
    echo 'This text will be visible by `POST` request.';
}

Check for GET Request

if(Request::method('get')) {
    echo 'This text will be visible by `GET` request.';
}

Getting the Requested Data

Getting the POST Request Data

echo Request::post('name', 'Anonymous');

The second parameter value in the code above will be used if the name data is not available inside $_POST or if the generated value is empty.

Another example using dot notation for accessing nested array data:

echo Request::post('name.first', 'Anonymous');
echo Request::post('name.last', "");

Getting the GET Request Data

echo Request::get('name', 'Anonymous');

The second parameter value in the code above will be used if the name data is not available inside $_GET or if the generated value is empty.

Another example using dot notation for accessing nested array data:

echo Request::get('name.first', 'Anonymous');
echo Request::get('name.last', "");

Note: All of the retrieved value by this class will be parsed by Converter::strEval().

Donation and Email Subscription