Skip to content

Commit

Permalink
docs: add about missing protocol-relative link
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Feb 4, 2024
1 parent b0e1bf7 commit c2cbf05
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
15 changes: 10 additions & 5 deletions user_guide_src/source/helpers/url_helper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ The following functions are available:

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

Expand Down Expand Up @@ -56,8 +56,8 @@ The following functions are available:

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

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

If you pass an empty string ``''`` as the second parameter, it returns
the protocol-relative link:

.. literalinclude:: url_helper/026.php

This is useful because unlike :php:func:`site_url()`, you can supply a
string to a file, such as an image or stylesheet. For example:

Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/helpers/url_helper/004.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php

// Returns like `http://example.com/blog/post/123`
echo base_url('blog/post/123');
4 changes: 4 additions & 0 deletions user_guide_src/source/helpers/url_helper/026.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

// Returns like `//example.com/blog/post/123`
echo base_url('blog/post/123', '');

0 comments on commit c2cbf05

Please sign in to comment.