blob: 6162a6664edb36a9904d6d519400205a01acaf19 [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001###########
2Input Class
3###########
4
5The Input Class serves two purposes:
6
7#. It pre-processes global input data for security.
Andrey Andreev303eef02012-11-06 14:55:48 +02008#. It provides some helper methods for fetching input data and pre-processing it.
Derek Jones8ede1a22011-10-05 13:34:52 -05009
10.. note:: This class is initialized automatically by the system so there
11 is no need to do it manually.
12
Andrey Andreev04535c72014-01-06 10:57:05 +020013.. contents::
14 :local:
15
16.. raw:: html
17
18 <div class="custom-index container"></div>
19
Derek Jones8ede1a22011-10-05 13:34:52 -050020Security Filtering
21==================
22
Andrey Andreev303eef02012-11-06 14:55:48 +020023The security filtering method is called automatically when a new
Derek Jones8ede1a22011-10-05 13:34:52 -050024:doc:`controller <../general/controllers>` is invoked. It does the
25following:
26
Andrey Andreev04535c72014-01-06 10:57:05 +020027- If ``$config['allow_get_array']`` is FALSE (default is TRUE), destroys
Derek Jones8ede1a22011-10-05 13:34:52 -050028 the global GET array.
29- Destroys all global variables in the event register_globals is
30 turned on.
31- Filters the GET/POST/COOKIE array keys, permitting only alpha-numeric
32 (and a few other) characters.
33- Provides XSS (Cross-site Scripting Hacks) filtering. This can be
34 enabled globally, or upon request.
Andrey Andreevbfb635b2014-01-08 18:32:05 +020035- Standardizes newline characters to ``PHP_EOL`` (\\n in UNIX-based OSes,
36 \\r\\n under Windows). This is configurable.
Derek Jones8ede1a22011-10-05 13:34:52 -050037
38XSS Filtering
39=============
40
41The Input class has the ability to filter input automatically to prevent
42cross-site scripting attacks. If you want the filter to run
43automatically every time it encounters POST or COOKIE data you can
Andrey Andreev04535c72014-01-06 10:57:05 +020044enable it by opening your *application/config/config.php* file and setting
Derek Jones8ede1a22011-10-05 13:34:52 -050045this::
46
47 $config['global_xss_filtering'] = TRUE;
48
49Please refer to the :doc:`Security class <security>` documentation for
50information on using XSS Filtering in your application.
51
Andrey Andreev9cf12d12012-06-13 10:19:59 +030052Using POST, GET, COOKIE, or SERVER Data
53=======================================
Derek Jones8ede1a22011-10-05 13:34:52 -050054
Andrey Andreev04535c72014-01-06 10:57:05 +020055CodeIgniter comes with helper methods that let you fetch POST, GET,
Derek Jones8ede1a22011-10-05 13:34:52 -050056COOKIE or SERVER items. The main advantage of using the provided
Andrey Andreev303eef02012-11-06 14:55:48 +020057methods rather than fetching an item directly (``$_POST['something']``)
Andrey Andreev9cf12d12012-06-13 10:19:59 +030058is that the methods will check to see if the item is set and return
59NULL if not. This lets you conveniently use data without
Derek Jones8ede1a22011-10-05 13:34:52 -050060having to test whether an item exists first. In other words, normally
61you might do something like this::
62
Phil Sturgeon55a6ddb2012-05-23 18:37:24 +010063 $something = isset($_POST['something']) ? $_POST['something'] : NULL;
Derek Jones8ede1a22011-10-05 13:34:52 -050064
Andrey Andreev303eef02012-11-06 14:55:48 +020065With CodeIgniter's built in methods you can simply do this::
Derek Jones8ede1a22011-10-05 13:34:52 -050066
67 $something = $this->input->post('something');
68
Andrey Andreev04535c72014-01-06 10:57:05 +020069The main methods are:
Derek Jones8ede1a22011-10-05 13:34:52 -050070
Andrey Andreev28c2c972014-02-08 04:27:48 +020071- ``$this->input->post()``
72- ``$this->input->get()``
73- ``$this->input->cookie()``
74- ``$this->input->server()``
Derek Jones8ede1a22011-10-05 13:34:52 -050075
Andrey Andreev303eef02012-11-06 14:55:48 +020076Using the php://input stream
77============================
78
79If you want to utilize the PUT, DELETE, PATCH or other exotic request
80methods, they can only be accessed via a special input stream, that
81can only be read once. This isn't as easy as just reading from e.g.
82the ``$_POST`` array, because it will always exist and you can try
83and access multiple variables without caring that you might only have
84one shot at all of the POST data.
85
86CodeIgniter will take care of that for you, and you can access data
87from the **php://input** stream at any time, just by calling the
88``input_stream()`` method::
89
90 $this->input->input_stream('key');
91
Andrey Andreev04535c72014-01-06 10:57:05 +020092Similar to other methods such as ``get()`` and ``post()``, if the
93requested data is not found, it will return NULL and you can also
94decide whether to run the data through ``xss_clean()`` by passing
95a boolean value as the second parameter::
Andrey Andreev303eef02012-11-06 14:55:48 +020096
97 $this->input->input_stream('key', TRUE); // XSS Clean
98 $this->input->input_stream('key', FALSE); // No XSS filter
99
Andrey Andreev04535c72014-01-06 10:57:05 +0200100.. note:: You can utilize ``method()`` in order to know if you're reading
Andrey Andreev303eef02012-11-06 14:55:48 +0200101 PUT, DELETE or PATCH data.
102
Andrey Andreev04535c72014-01-06 10:57:05 +0200103***************
104Class Reference
105***************
Derek Jones8ede1a22011-10-05 13:34:52 -0500106
Andrey Andreev04535c72014-01-06 10:57:05 +0200107.. class:: CI_Input
Derek Jones8ede1a22011-10-05 13:34:52 -0500108
Andrey Andreev88ebdf72014-01-08 17:28:02 +0200109 .. method:: post([$index = NULL[, $xss_clean = NULL]])
Derek Jones8ede1a22011-10-05 13:34:52 -0500110
Andrey Andreev28c2c972014-02-08 04:27:48 +0200111 :param string $index: POST parameter name
112 :param bool $xss_clean: Whether to apply XSS filtering
113 :returns: $_POST if no parameters supplied, otherwise the POST value if found or NULL if not
114 :rtype: mixed
Derek Jones8ede1a22011-10-05 13:34:52 -0500115
Andrey Andreev04535c72014-01-06 10:57:05 +0200116 The first parameter will contain the name of the POST item you are
117 looking for::
Derek Jones8831d112011-10-05 15:57:02 -0500118
Andrey Andreev04535c72014-01-06 10:57:05 +0200119 $this->input->post('some_data');
Derek Jones8ede1a22011-10-05 13:34:52 -0500120
Andrey Andreev04535c72014-01-06 10:57:05 +0200121 The method returns NULL if the item you are attempting to retrieve
122 does not exist.
Derek Jones8ede1a22011-10-05 13:34:52 -0500123
Andrey Andreev04535c72014-01-06 10:57:05 +0200124 The second optional parameter lets you run the data through the XSS
Andrey Andreev88ebdf72014-01-08 17:28:02 +0200125 filter. It's enabled by setting the second parameter to boolean TRUE
126 or by setting your ``$config['global_xss_filtering']`` to TRUE.
Andrey Andreev04535c72014-01-06 10:57:05 +0200127 ::
Derek Jones8ede1a22011-10-05 13:34:52 -0500128
Andrey Andreev04535c72014-01-06 10:57:05 +0200129 $this->input->post('some_data', TRUE);
Derek Jones8ede1a22011-10-05 13:34:52 -0500130
Andrey Andreev04535c72014-01-06 10:57:05 +0200131 To return an array of all POST items call without any parameters.
Derek Jones8ede1a22011-10-05 13:34:52 -0500132
Andrey Andreev04535c72014-01-06 10:57:05 +0200133 To return all POST items and pass them through the XSS filter set the
134 first parameter NULL while setting the second parameter to boolean TRUE.
135 ::
Derek Jones8ede1a22011-10-05 13:34:52 -0500136
Andrey Andreev04535c72014-01-06 10:57:05 +0200137 $this->input->post(NULL, TRUE); // returns all POST items with XSS filter
Andrey Andreev88ebdf72014-01-08 17:28:02 +0200138 $this->input->post(NULL, FALSE); // returns all POST items without XSS filter
Derek Jones8ede1a22011-10-05 13:34:52 -0500139
Andrey Andreev88ebdf72014-01-08 17:28:02 +0200140 .. method:: get([$index = NULL[, $xss_clean = NULL]])
Derek Jones8ede1a22011-10-05 13:34:52 -0500141
Andrey Andreev28c2c972014-02-08 04:27:48 +0200142 :param string $index: GET parameter name
143 :param bool $xss_clean: Whether to apply XSS filtering
144 :returns: $_GET if no parameters supplied, otherwise the GET value if found or NULL if not
145 :rtype: mixed
Derek Jones8ede1a22011-10-05 13:34:52 -0500146
Andrey Andreev04535c72014-01-06 10:57:05 +0200147 This method is identical to ``post()``, only it fetches GET data.
148 ::
Derek Jones8ede1a22011-10-05 13:34:52 -0500149
Andrey Andreev04535c72014-01-06 10:57:05 +0200150 $this->input->get('some_data', TRUE);
151
152 To return an array of all GET items call without any parameters.
153
154 To return all GET items and pass them through the XSS filter set the
155 first parameter NULL while setting the second parameter to boolean TRUE.
156 ::
157
158 $this->input->get(NULL, TRUE); // returns all GET items with XSS filter
Andrey Andreev88ebdf72014-01-08 17:28:02 +0200159 $this->input->get(NULL, FALSE); // returns all GET items without XSS filtering
Andrey Andreev04535c72014-01-06 10:57:05 +0200160
Andrey Andreev7c60b122014-02-08 18:47:19 +0200161 .. method:: post_get($index[, $xss_clean = NULL])
Andrey Andreevea801ab2014-01-20 15:03:43 +0200162
Andrey Andreev28c2c972014-02-08 04:27:48 +0200163 :param string $index: POST/GET parameter name
164 :param bool $xss_clean: Whether to apply XSS filtering
165 :returns: POST/GET value if found, NULL if not
166 :rtype: mixed
Andrey Andreevea801ab2014-01-20 15:03:43 +0200167
Andrey Andreev7c60b122014-02-08 18:47:19 +0200168 This method works pretty much the same way as ``post()`` and ``get()``,
169 only combined. It will search through both POST and GET streams for data,
170 looking in POST first, and then in GET::
Andrey Andreevea801ab2014-01-20 15:03:43 +0200171
172 $this->input->post_get('some_data', TRUE);
173
Andrey Andreev7c60b122014-02-08 18:47:19 +0200174 .. method:: get_post($index[, $xss_clean = NULL])
Andrey Andreev04535c72014-01-06 10:57:05 +0200175
Andrey Andreev28c2c972014-02-08 04:27:48 +0200176 :param string $index: GET/POST parameter name
177 :param bool $xss_clean: Whether to apply XSS filtering
178 :returns: GET/POST value if found, NULL if not
179 :rtype: mixed
Andrey Andreev04535c72014-01-06 10:57:05 +0200180
Andrey Andreevea801ab2014-01-20 15:03:43 +0200181 This method works the same way as ``post_get()`` only it looks for GET
182 data first.
Andrey Andreev04535c72014-01-06 10:57:05 +0200183
184 $this->input->get_post('some_data', TRUE);
185
Andrey Andreevea801ab2014-01-20 15:03:43 +0200186 .. note:: This method used to act EXACTLY like ``post_get()``, but it's
187 behavior has changed in CodeIgniter 3.0.
188
Andrey Andreev7c60b122014-02-08 18:47:19 +0200189 .. method:: cookie([$index = NULL[, $xss_clean = NULL]])
Andrey Andreev04535c72014-01-06 10:57:05 +0200190
Andrey Andreev28c2c972014-02-08 04:27:48 +0200191 :param string $index: COOKIE parameter name
192 :param bool $xss_clean: Whether to apply XSS filtering
193 :returns: $_COOKIE if no parameters supplied, otherwise the COOKIE value if found or NULL if not
194 :rtype: mixed
Andrey Andreev04535c72014-01-06 10:57:05 +0200195
196 This method is identical to ``post()`` and ``get()``, only it fetches cookie
197 data::
198
199 $this->input->cookie('some_cookie');
200 $this->input->cookie('some_cookie, TRUE); // with XSS filter
201
Andrey Andreev7c60b122014-02-08 18:47:19 +0200202 .. method:: server($index[, $xss_clean = NULL])
Andrey Andreev04535c72014-01-06 10:57:05 +0200203
Andrey Andreev28c2c972014-02-08 04:27:48 +0200204 :param string $index: Value name
205 :param bool $xss_clean: Whether to apply XSS filtering
206 :returns: $_SERVER item value if found, NULL if not
207 :rtype: mixed
Andrey Andreev04535c72014-01-06 10:57:05 +0200208
Andrey Andreev7c60b122014-02-08 18:47:19 +0200209 This method is identical to the ``post()``, ``get()`` and ``cookie()``
210 methods, only it fetches server data (``$_SERVER``)::
Andrey Andreev04535c72014-01-06 10:57:05 +0200211
212 $this->input->server('some_data');
213
Andrey Andreev7c60b122014-02-08 18:47:19 +0200214 .. method:: input_stream([$index = NULL[, $xss_clean = NULL]])
Andrey Andreev04535c72014-01-06 10:57:05 +0200215
Andrey Andreev28c2c972014-02-08 04:27:48 +0200216 :param string $index: Key name
217 :param bool $xss_clean: Whether to apply XSS filtering
218 :returns: Input stream array if no parameters supplied, otherwise the specified value if found or NULL if not
219 :rtype: mixed
Andrey Andreev04535c72014-01-06 10:57:05 +0200220
221 This method is identical to ``get()``, ``post()`` and ``cookie()``,
222 only it fetches the *php://input* stream data.
223
224 .. method:: set_cookie($name = ''[, $value = ''[, $expire = ''[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = FALSE[, $httponly = FALSE]]]]]]])
225
Andrey Andreev28c2c972014-02-08 04:27:48 +0200226 :param mixed $name: Cookie name or an array of parameters
227 :param string $value: Cookie value
228 :param int $expire: Cookie expiration time in seconds
229 :param string $domain: Cookie domain
230 :param string $path: Cookie path
231 :param string $prefix: Cookie name prefix
232 :param bool $secure: Whether to only transfer the cookie through HTTPS
233 :param bool $httponly: Whether to only make the cookie accessible for HTTP requests (no JavaScript)
234 :rtype: void
235
Andrey Andreev04535c72014-01-06 10:57:05 +0200236
237 Sets a cookie containing the values you specify. There are two ways to
238 pass information to this method so that a cookie can be set: Array
239 Method, and Discrete Parameters:
240
Connor Tumbleson75b3fb22014-01-11 06:58:43 -0600241 **Array Method**
Andrey Andreev04535c72014-01-06 10:57:05 +0200242
243 Using this method, an associative array is passed to the first
244 parameter::
245
246 $cookie = array(
247 'name' => 'The Cookie Name',
248 'value' => 'The Value',
249 'expire' => '86500',
250 'domain' => '.some-domain.com',
251 'path' => '/',
252 'prefix' => 'myprefix_',
253 'secure' => TRUE
254 );
255
256 $this->input->set_cookie($cookie);
257
Andrey Andreev28c2c972014-02-08 04:27:48 +0200258 **Notes**
Andrey Andreev04535c72014-01-06 10:57:05 +0200259
260 Only the name and value are required. To delete a cookie set it with the
261 expiration blank.
262
263 The expiration is set in **seconds**, which will be added to the current
264 time. Do not include the time, but rather only the number of seconds
265 from *now* that you wish the cookie to be valid. If the expiration is
266 set to zero the cookie will only last as long as the browser is open.
267
268 For site-wide cookies regardless of how your site is requested, add your
269 URL to the **domain** starting with a period, like this:
270 .your-domain.com
271
272 The path is usually not needed since the method sets a root path.
273
274 The prefix is only needed if you need to avoid name collisions with
275 other identically named cookies for your server.
276
277 The secure boolean is only needed if you want to make it a secure cookie
278 by setting it to TRUE.
279
Connor Tumbleson75b3fb22014-01-11 06:58:43 -0600280 **Discrete Parameters**
Andrey Andreev04535c72014-01-06 10:57:05 +0200281
282 If you prefer, you can set the cookie by passing data using individual
283 parameters::
284
285 $this->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);
Derek Jones8ede1a22011-10-05 13:34:52 -0500286
Andrey Andreev04535c72014-01-06 10:57:05 +0200287 .. method:: ip_address()
Derek Jones8ede1a22011-10-05 13:34:52 -0500288
Andrey Andreev28c2c972014-02-08 04:27:48 +0200289 :returns: Visitor's IP address or '0.0.0.0' if not valid
290 :rtype: string
Derek Jones8ede1a22011-10-05 13:34:52 -0500291
Andrey Andreev04535c72014-01-06 10:57:05 +0200292 Returns the IP address for the current user. If the IP address is not
293 valid, the method will return '0.0.0.0'::
Derek Jones8ede1a22011-10-05 13:34:52 -0500294
Andrey Andreev04535c72014-01-06 10:57:05 +0200295 echo $this->input->ip_address();
Derek Jones8ede1a22011-10-05 13:34:52 -0500296
Andrey Andreev04535c72014-01-06 10:57:05 +0200297 .. important:: This method takes into account the ``$config['proxy_ips']``
298 setting and will return the reported HTTP_X_FORWARDED_FOR,
299 HTTP_CLIENT_IP, HTTP_X_CLIENT_IP or HTTP_X_CLUSTER_CLIENT_IP
300 address for the allowed IP addresses.
Derek Jones8ede1a22011-10-05 13:34:52 -0500301
Andrey Andreev04535c72014-01-06 10:57:05 +0200302 .. method:: valid_ip($ip[, $which = ''])
Andrey Andreev303eef02012-11-06 14:55:48 +0200303
Andrey Andreev28c2c972014-02-08 04:27:48 +0200304 :param string $ip: IP address
305 :param string $which: IP protocol ('ipv4' or 'ipv6')
306 :returns: TRUE if the address is valid, FALSE if not
307 :rtype: bool
Derek Jones8ede1a22011-10-05 13:34:52 -0500308
Andrey Andreev04535c72014-01-06 10:57:05 +0200309 Takes an IP address as input and returns TRUE or FALSE (boolean) depending
310 on whether it is valid or not.
Derek Jones8ede1a22011-10-05 13:34:52 -0500311
Andrey Andreev04535c72014-01-06 10:57:05 +0200312 .. note:: The $this->input->ip_address() method above automatically
313 validates the IP address.
Derek Jones8ede1a22011-10-05 13:34:52 -0500314
Andrey Andreev04535c72014-01-06 10:57:05 +0200315 ::
Andrey Andreev5a257182012-06-10 06:18:14 +0300316
Andrey Andreev04535c72014-01-06 10:57:05 +0200317 if ( ! $this->input->valid_ip($ip))
318 {
319 echo 'Not Valid';
320 }
321 else
322 {
323 echo 'Valid';
324 }
Derek Jones8ede1a22011-10-05 13:34:52 -0500325
Andrey Andreev04535c72014-01-06 10:57:05 +0200326 Accepts an optional second string parameter of 'ipv4' or 'ipv6' to specify
327 an IP format. The default checks for both formats.
Derek Jones8ede1a22011-10-05 13:34:52 -0500328
Andrey Andreev04535c72014-01-06 10:57:05 +0200329 .. method:: user_agent()
Derek Jones8ede1a22011-10-05 13:34:52 -0500330
Andrey Andreev28c2c972014-02-08 04:27:48 +0200331 :returns: User agent string or NULL if not set
332 :rtype: mixed
Derek Jones8ede1a22011-10-05 13:34:52 -0500333
Andrey Andreev04535c72014-01-06 10:57:05 +0200334 Returns the user agent string (web browser) being used by the current user,
335 or NULL if it's not available.
336 ::
Derek Jones8ede1a22011-10-05 13:34:52 -0500337
Andrey Andreev04535c72014-01-06 10:57:05 +0200338 echo $this->input->user_agent();
Derek Jones8ede1a22011-10-05 13:34:52 -0500339
Andrey Andreev04535c72014-01-06 10:57:05 +0200340 See the :doc:`User Agent Class <user_agent>` for methods which extract
341 information from the user agent string.
Derek Jones8ede1a22011-10-05 13:34:52 -0500342
Andrey Andreev04535c72014-01-06 10:57:05 +0200343 .. method:: request_headers([$xss_clean = FALSE])
Derek Jones8ede1a22011-10-05 13:34:52 -0500344
Andrey Andreev28c2c972014-02-08 04:27:48 +0200345 :param bool $xss_clean: Whether to apply XSS filtering
346 :returns: An array of HTTP request headers
347 :rtype: array
Derek Jones8ede1a22011-10-05 13:34:52 -0500348
Andrey Andreev04535c72014-01-06 10:57:05 +0200349 Returns an array of HTTP request headers.
350 Useful if running in a non-Apache environment where
351 `apache_request_headers() <http://php.net/apache_request_headers>`_
352 will not be supported.
353 ::
Derek Jones8ede1a22011-10-05 13:34:52 -0500354
Andrey Andreev04535c72014-01-06 10:57:05 +0200355 $headers = $this->input->request_headers();
Derek Jones8ede1a22011-10-05 13:34:52 -0500356
Andrey Andreev04535c72014-01-06 10:57:05 +0200357 .. method:: get_request_header($index[, $xss_clean = FALSE])
Derek Jones8ede1a22011-10-05 13:34:52 -0500358
Andrey Andreev28c2c972014-02-08 04:27:48 +0200359 :param string $index: HTTP request header name
360 :param bool $xss_clean: Whether to apply XSS filtering
361 :returns: An HTTP request header or NULL if not found
362 :rtype: string
Derek Jones8ede1a22011-10-05 13:34:52 -0500363
Andrey Andreev04535c72014-01-06 10:57:05 +0200364 Returns a single member of the request headers array or NULL
365 if the searched header is not found.
366 ::
Derek Jones8ede1a22011-10-05 13:34:52 -0500367
Andrey Andreev04535c72014-01-06 10:57:05 +0200368 $this->input->get_request_header('some-header', TRUE);
Derek Jones8ede1a22011-10-05 13:34:52 -0500369
Andrey Andreev04535c72014-01-06 10:57:05 +0200370 .. method:: is_ajax_request()
Derek Jones8ede1a22011-10-05 13:34:52 -0500371
Andrey Andreev28c2c972014-02-08 04:27:48 +0200372 :returns: TRUE if it is an Ajax request, FALSE if not
373 :rtype: bool
Derek Jones8ede1a22011-10-05 13:34:52 -0500374
Andrey Andreev04535c72014-01-06 10:57:05 +0200375 Checks to see if the HTTP_X_REQUESTED_WITH server header has been
376 set, and returns boolean TRUE if it is or FALSE if not.
Derek Jones8ede1a22011-10-05 13:34:52 -0500377
Andrey Andreev04535c72014-01-06 10:57:05 +0200378 .. method:: is_cli_request()
Derek Jones8ede1a22011-10-05 13:34:52 -0500379
Andrey Andreev28c2c972014-02-08 04:27:48 +0200380 :returns: TRUE if it is a CLI request, FALSE if not
381 :rtype: bool
Michiel Vugteveenbe0ca262012-03-07 19:09:51 +0100382
Andrey Andreev04535c72014-01-06 10:57:05 +0200383 Checks to see if the application was run from the command-line
384 interface.
Michiel Vugteveenbe0ca262012-03-07 19:09:51 +0100385
Andrey Andreev04535c72014-01-06 10:57:05 +0200386 .. note:: This method checks both the PHP SAPI name currently in use
387 and if the ``STDIN`` constant is defined, which is usually a
388 failsafe way to see if PHP is being run via the command line.
Michiel Vugteveenbe0ca262012-03-07 19:09:51 +0100389
Andrey Andreev04535c72014-01-06 10:57:05 +0200390 ::
391
392 $this->input->is_cli_request()
393
Andrey Andreevea801ab2014-01-20 15:03:43 +0200394 .. note:: This method is DEPRECATED and is now just an alias for the
395 :func:`is_cli()` function.
396
Andrey Andreev04535c72014-01-06 10:57:05 +0200397 .. method:: method([$upper = FALSE])
398
Andrey Andreev28c2c972014-02-08 04:27:48 +0200399 :param bool $upper: Whether to return the request method name in upper or lower case
400 :returns: HTTP request method
401 :rtype: string
Andrey Andreev04535c72014-01-06 10:57:05 +0200402
403 Returns the ``$_SERVER['REQUEST_METHOD']``, with the option to set it
404 in uppercase or lowercase.
405 ::
406
407 echo $this->input->method(TRUE); // Outputs: POST
408 echo $this->input->method(FALSE); // Outputs: post
409 echo $this->input->method(); // Outputs: post