PHP getservbyname() Function
Example
A getservbyname() example:
<?php
$portnum = getservbyname("http", "tcp");
echo $portnum;
?>
Definition and Usage
The getservbyname() function returns the port number for a given Internet service and protocol.
Syntax
getservbyname(service, protocol)
Parameter Values
Parameter | Description |
---|---|
service | Required. Specifies the Internet service name (like "http") |
protocol | Required. Specifies a protocol name (like "tcp" or "udp") |
Technical Details
Return Value: | The port number on success. FALSE on failure |
---|---|
PHP Version: | 4.0+ |
❮ PHP Network Reference