Message-ID: <1929146270.10595.1711629599655.JavaMail.confluence@docs1> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_10594_643165661.1711629599655" ------=_Part_10594_643165661.1711629599655 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html request

request

Description


Core\Request request()


Using our request() function will give you ac= cess to our core request class, which is used to handle incoming HTTP reque= sts.

Examples


=20
<?php

route('/foo', function() {

   /**
    * URL Example: /foo?hello=3D1
    */
   if (request()->get('hello')) {
      echo "Hello!";
   }

   // Checks if a form has been posted
   if (request()->isPost()) {

   }

   /**
    * URL Example: /foo/bar
    */
   echo request()->segment(1); // Prints foo
   echo request()->segment(2); // Prints bar

});
=20

Methods


Method Description Usage Returns

get(string $var)

 


$var

Provide th= e HTTP request key

Returns the HTTP request = value.

=20
/**
 * URL Example: /foo?hello=3D1
 */
if (request()->get('hello')) {
   echo "Hello!";
}
=20

HTTP request value on success, = null on failure.

This supports all incoming HTTP
= requests (e.g. GET, POST, DELETE etc...) 

isPost()

Checks to see if a form has bee= n posted.

=20
if (request(=
)->isPost()) {

}
=20

true on succes= s, false on failure.

= This method only checks POST requests.

segment(int $number)

 


$number

Provide= the segment number
of the URL. 

Returns URL segment based on th= e
forward slash. 

 

=20
/**
 * URL Example: /foo/bar
 */
echo request()->segment(1); // Prints foo
echo request()->segment(2); // Prints bar
=20
Segment value on success, = null on failure.
------=_Part_10594_643165661.1711629599655--