url_set_protocol
urlChanges the protocol of a URL
Syntax
url_set_protocol(url, protocol) Parameters
url (string) The URL string to modify
protocol (string) The new protocol to set (e.g., "https", "http")
Returns
string The URL with the updated protocol
Examples
Input:
url_set_protocol("http://example.com", "https") Output:
"https://example.com" Input:
url_set_protocol("http://example.com/path?query=value", "https") Output:
"https://example.com/path?query=value" The url_set_protocol() function replaces the protocol (scheme) of a URL with a new protocol, preserving all other URL components.
Usage
Use url_set_protocol() when you need to change URL protocols in bulk, such as converting all HTTP URLs to HTTPS for security compliance or changing protocols for API endpoints.