Skip to content

Commit c2cbf05

Browse files
committed
docs: add about missing protocol-relative link
1 parent b0e1bf7 commit c2cbf05

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

user_guide_src/source/helpers/url_helper.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ The following functions are available:
2020

2121
.. php:function:: site_url([$uri = ''[, $protocol = null[, $altConfig = null]]])
2222
23-
:param array|string $uri: URI string or array of URI segments
24-
:param string $protocol: Protocol, e.g., 'http' or 'https'
25-
:param \\Config\\App $altConfig: Alternate configuration to use
23+
:param array|string $uri: URI string or array of URI segments.
24+
:param string $protocol: Protocol, e.g., 'http' or 'https'. If empty string '' is set, a protocol-relative link is returned.
25+
:param \\Config\\App $altConfig: Alternate configuration to use.
2626
:returns: Site URL
2727
:rtype: string
2828

@@ -56,8 +56,8 @@ The following functions are available:
5656

5757
.. php:function:: base_url([$uri = ''[, $protocol = null]])
5858
59-
:param array|string $uri: URI string or array of URI segments
60-
:param string $protocol: Protocol, e.g., 'http' or 'https'
59+
:param array|string $uri: URI string or array of URI segments.
60+
:param string $protocol: Protocol, e.g., 'http' or 'https'. If empty string '' is set, a protocol-relative link is returned.
6161
:returns: Base URL
6262
:rtype: string
6363

@@ -83,6 +83,11 @@ The following functions are available:
8383
The above example would return something like:
8484
**http://example.com/blog/post/123**
8585

86+
If you pass an empty string ``''`` as the second parameter, it returns
87+
the protocol-relative link:
88+
89+
.. literalinclude:: url_helper/026.php
90+
8691
This is useful because unlike :php:func:`site_url()`, you can supply a
8792
string to a file, such as an image or stylesheet. For example:
8893

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<?php
22

3+
// Returns like `http://example.com/blog/post/123`
34
echo base_url('blog/post/123');
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
// Returns like `//example.com/blog/post/123`
4+
echo base_url('blog/post/123', '');

0 commit comments

Comments
 (0)