|
|
|
@ -84,15 +84,17 @@
|
|
|
|
|
* @param string $url The URL to slice the path from.
|
|
|
|
|
* @param bool $include_scheme [optional]
|
|
|
|
|
* Includes the scheme. `true` by default.
|
|
|
|
|
* @param bool $include_scheme [optional]
|
|
|
|
|
* Includes the port. `true` by default.
|
|
|
|
|
* @return string A URL composed of the original scheme (unless specified),
|
|
|
|
|
* hostname, and port (if present).
|
|
|
|
|
*/
|
|
|
|
|
function url_get_base(string $url, bool $include_scheme = true) {
|
|
|
|
|
function url_get_base(string $url, bool $include_scheme = true, bool $include_port = true) {
|
|
|
|
|
$url_components = parse_url($url);
|
|
|
|
|
$scheme = $url_components['scheme'];
|
|
|
|
|
$host = $url_components['host'];
|
|
|
|
|
|
|
|
|
|
if (isset($url_components['port'])) {
|
|
|
|
|
if (isset($url_components['port']) && $include_port) {
|
|
|
|
|
$port = $url_components['port'];
|
|
|
|
|
$host .= ":$port";
|
|
|
|
|
}
|
|
|
|
|