URL.php
WIKINDX : Bibliographic Management system.
Tags
Table of Contents
Functions
- build_query() : string
- Generate URL-encoded query string according to RFC 3986
- escape() : string
- Escape a component of a URL according to RFC 3986
- reduceUrl() : string
- Reduce the size of long URL to keep web browser display tidy
- getCurrentProtocol() : string
- Return the protocol requested by the HTTP client
- getVhost() : string
- Return the vHost name (Virtual Hostname)
- URL_exists() : bool
- Check that an internet resource exists
Functions
build_query()
Generate URL-encoded query string according to RFC 3986
build_query(array<string|int, mixed>|object $data) : string
This function is a wrapper for http_build_query() where $encoding_type parameter is always PHP_QUERY_RFC3986
Parameters
- $data : array<string|int, mixed>|object
-
Array or object key-value pairs
Return values
stringescape()
Escape a component of a URL according to RFC 3986
escape(mixed $url) : string
This function attempts to split a URL into its components and recompose it after decoding and re-encoding the components.
A well-constructed URL should not suffer from this operation. Those that are malformed can be corrected but if an & character appears in the parameters, parameters may disappear.
Use the \URL\build_query() function to construct well-encoded parameters.
If $url is not a string, $url is casted to string type before escaping.
Parameters
- $url : mixed
-
URL
Tags
Return values
stringreduceUrl()
Reduce the size of long URL to keep web browser display tidy
reduceUrl(string $url[, int|null $limit = NULL ]) : string
Parameters
- $url : string
-
URL to reduce
- $limit : int|null = NULL
-
Max number unicode characters (Default is the value of user option 'StringLimit')
Return values
stringgetCurrentProtocol()
Return the protocol requested by the HTTP client
getCurrentProtocol() : string
Return values
string —http or https (in lowercase)
getVhost()
Return the vHost name (Virtual Hostname)
getVhost() : string
Read also the special 'CLI_VHOST' constant which can be defined to simulate a vHost in CLI mode.
Return an empty string when the vHost cannot be read.
Return values
stringURL_exists()
Check that an internet resource exists
URL_exists(string $url) : bool
The resource is queried with the HTTP protocol to find out if it really exists online. The HTTP error code returned must be between 200 and 300.
Parameters
- $url : string