Skip to content

Commit 4e48de9

Browse files
committed
docs: move getVar() section down
The method is not recommended.
1 parent 2032f7d commit 4e48de9

1 file changed

Lines changed: 44 additions & 14 deletions

File tree

‎user_guide_src/source/incoming/incomingrequest.rst‎

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,37 +100,67 @@ With CodeIgniter's built-in methods you can simply do this:
100100
Getting Data
101101
============
102102

103-
getVar()
103+
getGet()
104104
--------
105105

106-
The ``getVar()`` method will pull from ``$_REQUEST``, so will return any data from ``$_GET``, ``$POST``, or ``$_COOKIE`` (depending on php.ini `request-order <https://www.php.net/manual/en/ini.core.php#ini.request-order>`_).
107-
108-
.. warning:: If you want to validate POST data only, don't use ``getVar()``.
109-
Newer values override older values. POST values may be overridden by the
110-
cookies if they have the same name, and you set "C" after "P" in
111-
`request-order <https://www.php.net/manual/en/ini.core.php#ini.request-order>`_.
106+
The ``getGet()`` method will pull from ``$_GET``.
112107

113-
.. note:: If the incoming request has a ``Content-Type`` header set to ``application/json``,
114-
the ``getVar()`` method returns the JSON data instead of ``$_REQUEST`` data.
108+
* ``$request->getGet()``
115109

116-
get*()
117-
------
110+
getPost()
111+
---------
118112

119-
While this
120-
is convenient, you will often need to use a more specific method, like:
113+
The ``getPost()`` method will pull from ``$_POST``.
121114

122-
* ``$request->getGet()``
123115
* ``$request->getPost()``
116+
117+
getCookie()
118+
-----------
119+
120+
The ``getCookie()`` method will pull from ``$_COOKIE``.
121+
124122
* ``$request->getCookie()``
123+
124+
getServer()
125+
-----------
126+
127+
The ``getServer()`` method will pull from ``$_SERVER``.
128+
125129
* ``$request->getServer()``
130+
131+
getEnv()
132+
--------
133+
134+
The ``getEnv()`` method will pull from ``$_ENV``.
135+
126136
* ``$request->getEnv()``
127137

138+
getPostGet()
139+
------------
140+
128141
In addition, there are a few utility methods for retrieving information from either ``$_GET`` or ``$_POST``, while
129142
maintaining the ability to control the order you look for it:
130143

131144
* ``$request->getPostGet()`` - checks ``$_POST`` first, then ``$_GET``
145+
146+
getGetPost()
147+
------------
148+
132149
* ``$request->getGetPost()`` - checks ``$_GET`` first, then ``$_POST``
133150

151+
getVar()
152+
--------
153+
154+
The ``getVar()`` method will pull from ``$_REQUEST``, so will return any data from ``$_GET``, ``$POST``, or ``$_COOKIE`` (depending on php.ini `request-order <https://www.php.net/manual/en/ini.core.php#ini.request-order>`_).
155+
156+
.. warning:: If you want to validate POST data only, don't use ``getVar()``.
157+
Newer values override older values. POST values may be overridden by the
158+
cookies if they have the same name, and you set "C" after "P" in
159+
`request-order <https://www.php.net/manual/en/ini.core.php#ini.request-order>`_.
160+
161+
.. note:: If the incoming request has a ``Content-Type`` header set to ``application/json``,
162+
the ``getVar()`` method returns the JSON data instead of ``$_REQUEST`` data.
163+
134164
.. _incomingrequest-getting-json-data:
135165

136166
Getting JSON Data

0 commit comments

Comments
 (0)