Skip to content

Commit 4a4f55b

Browse files
authored
Merge pull request #7242 from kenjis/fix-docs-uri.rst
docs: fix uri.rst
2 parents df11b5b + d8954a1 commit 4a4f55b

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

user_guide_src/source/libraries/uri.rst

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ The Current URI
3131
---------------
3232

3333
Many times, all you really want is an object representing the current URL of this request.
34-
You can use one of the functions available in the **url_helper**:
34+
You can use one of the functions available in the :doc:`../helpers/url_helper`:
3535

3636
.. literalinclude:: uri/004.php
3737

3838
You must pass ``true`` as the first parameter, otherwise, it will return the string representation of the current URL.
39+
3940
This URI is based on the path (relative to your ``baseURL``) as determined by the current request object and
40-
your settings in ``Config\App`` (baseURL, indexPage, and forceGlobalSecureRequests).
41+
your settings in ``Config\App`` (``baseURL``, ``indexPage``, and ``forceGlobalSecureRequests``).
4142
Assuming that you're in a controller that extends ``CodeIgniter\Controller`` you can get this relative path:
4243

4344
.. literalinclude:: uri/005.php
@@ -95,7 +96,7 @@ If you do not want to display the port, pass in ``true`` as the only parameter:
9596

9697
.. note:: If the current port is the default port for the scheme it will never be displayed.
9798

98-
Userinfo
99+
UserInfo
99100
--------
100101

101102
The userinfo section is simply the username and password that you might see with an FTP URI. While you can get
@@ -138,31 +139,51 @@ can be used to manipulate it:
138139
Query
139140
-----
140141

141-
The query variables can be manipulated through the class using simple string representations. Query values can only
142+
The query data can be manipulated through the class using simple string representations.
143+
144+
Getting/Setting Query
145+
^^^^^^^^^^^^^^^^^^^^^
146+
147+
Query values can only
142148
be set as a string currently.
143149

144150
.. literalinclude:: uri/017.php
145151

152+
The ``setQuery()`` method overwrite any existing query variables.
153+
146154
.. note:: Query values cannot contain fragments. An InvalidArgumentException will be thrown if it does.
147155

156+
Setting Query from Array
157+
^^^^^^^^^^^^^^^^^^^^^^^^
158+
148159
You can set query values using an array:
149160

150161
.. literalinclude:: uri/018.php
151162

152-
The ``setQuery()`` and ``setQueryArray()`` methods overwrite any existing query variables. You can add a value to the
163+
The ``setQueryArray()`` method overwrite any existing query variables.
164+
165+
Adding Query Value
166+
^^^^^^^^^^^^^^^^^^
167+
168+
You can add a value to the
153169
query variables collection without destroying the existing query variables with the ``addQuery()`` method. The first
154170
parameter is the name of the variable, and the second parameter is the value:
155171

156172
.. literalinclude:: uri/019.php
157173

158-
**Filtering Query Values**
174+
Filtering Query Values
175+
^^^^^^^^^^^^^^^^^^^^^^
159176

160177
You can filter the query values returned by passing an options array to the ``getQuery()`` method, with either an
161178
*only* or an *except* key:
162179

163180
.. literalinclude:: uri/020.php
164181

165182
This only changes the values returned during this one call. If you need to modify the URI's query values more permanently,
183+
184+
Changing Query Values
185+
^^^^^^^^^^^^^^^^^^^^^
186+
166187
you can use the ``stripQuery()`` and ``keepQuery()`` methods to change the actual object's query variable collection:
167188

168189
.. literalinclude:: uri/021.php
@@ -174,7 +195,7 @@ you can use the ``stripQuery()`` and ``keepQuery()`` methods to change the actua
174195
Fragment
175196
--------
176197

177-
Fragments are the portion at the end of the URL, preceded by the pound-sign (#). In HTML URLs these are links
198+
Fragments are the portion at the end of the URL, preceded by the pound-sign (``#``). In HTML URLs these are links
178199
to an on-page anchor. Media URI's can make use of them in various other ways.
179200

180201
.. literalinclude:: uri/022.php

user_guide_src/source/libraries/uri/016.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
$uri = new \CodeIgniter\HTTP\URI('http://www.example.com/some/path');
44

5-
echo $uri->getPath(); // 'some/path'
6-
echo $uri->setPath('another/path')->getPath(); // 'another/path'
5+
echo $uri->getPath(); // '/some/path'
6+
echo $uri->setPath('/another/path')->getPath(); // '/another/path'

0 commit comments

Comments
 (0)