Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

PHP - Function getservbyname



Syntax

int getservbyname ( string $service , string $protocol )

Definition and Usage

It is used to get port numbers which has associated with an internet services

Return Values

It will return port numbers or else show the result as protocal is not found message on False condition

Parameters

Parameters Discription
service It contains service name
protocol It contains protocal information

Example

Try out following example

<?php
$services = array('http', 'ftp', 'ssh', 'telnet', 'imap',
'smtp', 'nicname', 'gopher', 'finger', 'pop3', 'www');

foreach ($services as $service) {
    $port = getservbyname($service, 'tcp');
    echo $service . ": " . $port . "<br />\n";
}
?>

Above Example gives the result as follows

php_function_reference.htm
Advertisements