Obtaining standard port for arbitrary protocols in PHP
Posted
by
Trott
on Stack Overflow
See other posts from Stack Overflow
or by Trott
Published on 2011-11-11T17:43:37Z
Indexed on
2011/11/11
17:52 UTC
Read the original article
Hit count: 91
I'm looking for a function that will accept a string representing the scheme portion of a URL (e.g., "http", "https", "ftp", etc.) and return the standard port. It might be used like this:
echo get_port_from_protocol("http"); // 80
As a last resort, I suppose I could write something to parse through /etc/services
(assuming I only need to run under UNIX-like operating systems).
But surely there must be something built-in to PHP, no?
© Stack Overflow or respective owner