Piwik\
Contains less commonly needed URL helper methods.
The class defines the following methods:
getQueryStringWithExcludedParameters() — Converts an array of query parameter name/value mappings into a query string.isLookLikeUrl() — Returns true if the string passed may be a URL ie.getParseUrlReverse() ash; Returns a URL created from the result of the parse_url function.getArrayFromQueryString() — Returns a URL query string as an array.getParameterFromQueryString() — Returns the value of a single query parameter from the supplied query string.getPathAndQueryFromUrl() — Returns the path and query string of a URL.getQueryFromUrl() — Returns the query part from any valid url and adds additional parameters to the query part if needed.getQueryStringWithExcludedParameters()Converts an array of query parameter name/value mappings into a query string.
Parameters that are in $parametersToExclude will not appear in the result.
It accepts the following parameter(s):
$queryParameters
Array of query parameters, eg, array('site' => '0', 'date' => '2012-01-01').$parametersToExclude
Array of query parameter names that shouldn't be in the result query string, eg, array('date', 'period').Returns: string —
A query string, eg, "?site=0".
isLookLikeUrl()Returns true if the string passed may be a URL ie. it starts with protocol://.
We don't need a precise test here because the value comes from the website tracked source code and the URLs may look very strange.
It accepts the following parameter(s):
$url (string) —It returns a bool value.
getParseUrlReverse()Returns a URL created from the result of the parse_url function.
Copied from the PHP comments at https://php.net/parse_url.
It accepts the following parameter(s):
$parsed (array) —
Result of parse_url.Returns: false|string —
The URL or false if $parsed isn't an array.
getArrayFromQueryString()Returns a URL query string as an array.
It accepts the following parameter(s):
$urlQuery (string) —
The query string, eg, '?param1=value1¶m2=value2'.Returns: array —
eg, array('param1' => 'value1', 'param2' => 'value2')
getParameterFromQueryString()Returns the value of a single query parameter from the supplied query string.
It accepts the following parameter(s):
$urlQuery (string) —
The query string.$parameter (string) —
The query parameter name to return.Returns: string|null —
Parameter value if found (can be the empty string!), null if not found.
getPathAndQueryFromUrl()Returns the path and query string of a URL.
It accepts the following parameter(s):
$url (string) —
The URL.$additionalParamsToAdd (array) —
If not empty the given parameters will be added to the query.$preserveAnchor (bool) —
If true then do not remove any #anchor from the url, default falseReturns: string —
eg, /test/index.php?module=CoreHome if $url is https://piwik.org/test/index.php?module=CoreHome.
getQueryFromUrl()Returns the query part from any valid url and adds additional parameters to the query part if needed.
It accepts the following parameter(s):
$url (string) —
Any url eg "https://example.com/piwik/?foo=bar"$additionalParamsToAdd (array) —
If not empty the given parameters will be added to the query.Returns: string —
eg. "foo=bar&foo2=bar2"