url_set_port
urlChanges the port of a URL
Syntax
url_set_port(url, port) Parameters
url (string) The URL string to modify
port (number) The new port number to set
Returns
string The URL with the updated port
Examples
Input:
url_set_port("https://example.com", 8080) Output:
"https://example.com:8080" Input:
url_set_port("https://example.com:3000/api", 443) Output:
"https://example.com:443/api" The url_set_port() function sets or changes the port number in a URL, preserving all other URL components including protocol, domain, path, and query parameters.
Usage
Use url_set_port() when you need to change port numbers in URLs, such as switching between development and production ports or updating service configurations.