url_parse
urlParses a URL into its component parts
Syntax
url_parse(url) Parameters
url (string) The URL string to parse
Returns
object Object containing protocol, domain, port, path, query, and fragment
Examples
Input:
url_parse("https://example.com:8080/path?key=value#section") Output:
{"protocol": "https", "domain": "example.com", "port": 8080, "path": "/path", "query": "key=value", "fragment": "section"} The url_parse() function breaks down a URL into its constituent components, returning an object with protocol, domain, port, path, query string, and fragment.
Usage
Use url_parse() when you need to analyze or manipulate specific parts of URLs, such as extracting domains for analytics or modifying paths.