array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'en', ), 'this' => array ( 0 => 'function.getprotobyname.php', 1 => 'getprotobyname', ), 'up' => array ( 0 => 'ref.network.php', 1 => 'Network Functions', ), 'prev' => array ( 0 => 'function.getmxrr.php', 1 => 'getmxrr', ), 'next' => array ( 0 => 'function.getprotobynumber.php', 1 => 'getprotobynumber', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/network/functions/getprotobyname.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
getprotobyname — Get protocol number associated with protocol name
getprotobyname() returns the protocol number
associated with the protocol protocol
as per
/etc/protocols.
protocol
The protocol name.
Returns the protocol number, or false
on failure.
Example #1 getprotobyname() example
<?php
$protocol = 'tcp';
$get_prot = getprotobyname($protocol);
if ($get_prot === FALSE) {
echo 'Invalid Protocol';
} else {
echo 'Protocol #' . $get_prot;
}
?>