add_query_arg ( string $key, string $value, string $url )

Retrieves a modified URL query string.

Return: (string)

Source file: app/functions/core-function.php

View source


Parameters

$key

(string) (Required) A query variable key.

$value

(string) (Required) A query variable value, or a URL to act upon.

$url

(string) (Required) A URL to act upon.


Uses


Source

function add_query_arg($key, $value, $url)
{
    $app = \Liten\Liten::getInstance();
    $uri = parse_url($url);
    $query = isset($uri['query']) ? $uri['query'] : '';
    parse_str($query, $params);
    $params[$key] = $value;
    $query = http_build_query($params);
    $result = '';
    if ($uri['scheme']) {
        $result .= $uri['scheme'] . ':';
    }
    if ($uri['host']) {
        $result .= '//' . $uri['host'];
    }
    if ($uri['port']) {
        $result .= $app->hook->apply_filter('query_arg_port', ':' . $uri['port']);
    }
    if ($uri['path']) {
        $result .= $uri['path'];
    }
    if ($query) {
        $result .= '?' . $query;
    }
    return $result;
}


Changelog

  • Since: eduTrac SIS 6.3.0

User Contributed Notes

You must log in before being able to contribute a note.