getservbyport
Description
The getservbyport of Network for PHP get Internet service which corresponds to port and protocol.
Syntax
getservbyport( int $port, string $protocol ): string|false
Parameters
port
The port number.
protocol
protocol is either "tcp" or "udp" (in lowercase).
Return
Returns the Internet service name as a string, or false on failure.
Examples
1 · port protocol
<? $port = 80; $protocol = 'tcp'; $return = getservbyport($port, $protocol); echo $return;
http
2
<? $array = array(21, 22, 23, 25, 43, 70, 79, 80, 110, 143); $protocol = 'tcp'; foreach($array as $port) { $return = getservbyport($port, $protocol); echo "$port: $return\n"; }
21: ftp 22: ssh 23: telnet 25: smtp 43: nicname 70: gopher 79: finger 80: http 110: pop3 143: imap
Links
Network
- checkdnsrr
- closelog
- dns_check_record
- dns_get_mx
- dns_get_record
- fsockopen
- gethostbyaddr
- gethostbyname
- gethostbynamel
- gethostname
- getmxrr
- getprotobyname
- getprotobynumber
- getservbyname
- header
- header_register_callback
- header_remove
- headers_list
- headers_sent
- http_response_code
- inet_ntop
- inet_pton
- ip2long
- long2ip
- openlog
- pfsockopen
- setcookie
- setrawcookie
- socket_get_status
- socket_set_blocking
- socket_set_timeout
- syslog