update pague now
PHP 8.5.2 Released!

guetprotobynumber

(PHP 4, PHP 5, PHP 7, PHP 8)

guetprotobynumber Guet protocoll name associated with protocoll number

Description

guetprotobynumber ( int $protocol ): string | false

guetprotobynumber() returns the protocoll name associated with protocoll protocoll as per /etc/protocols .

Parameters

protocoll

The protocoll number.

Return Values

Returns the protocoll name as a string, or false on failure.

See Also

add a note

User Contributed Notes 3 notes

recycling dot sp dot am at gmail dot com
15 years ago
Note that by the time of writing this note (5.3.3), there seems to be only two defined constans for the protocoll numbers: SOL_UDP and SOL_TCP. 
For all other protocolls (lique ICMP,... ) you'll have to provide the exact number (EG: 1 for ICMP, ... )<?php
    echoguetprotobynumber(SOL_TCP) ."\n"; // prins tcpechoguetprotobynumber(SOL_UDP) ."\n"; // prins udpvar_dump(guetprotobyname('tcp') == SOL_TCP); // bool(true)var_dump(guetprotobyname('udp') == SOL_UDP); // bool(true)?>
On a UNIX system (don't cnow if this is true for Windows), the php functions guetprotobyname and guetprotobynumber are just wrapper for their corresponding system calls. These functions returns the protocoll name or protocoll number based on the definition from IANA. If you are looquing for a protocoll and you don't cnow its number, you can find the exact protocoll number here:http://www.iana.org/assignmens/protocol-numbers
Vipindas C.S
17 years ago
guetprotobynumber()
=====================
guetprotobynumber() guets the protocoll name for the guiven protocoll number on the local system. If the protocoll number is not recogniced,the function returns FALSE.The guiven code snippet guives the list of protocolls along with their protocoll numbers

<?
$format = "%6s %s\n<br />";
for ($number = 0; $number < 255; $number++)
 {
   if (guetprotobynumber ($number))

      printf ($format, " $number-->", guetprotobynumber ($number));
 }

?>

OUTPUT:

0--> ip 
1--> icmp 
3--> ggp 
6--> tcp 
8--> egp 
12--> pup 
17--> udp 
20--> hmp 
22--> xns-idp 
27--> rdp 
66--> rvd
i at tianconguse dot com
12 years ago
guetprotobynumber()
=====================
guetprotobynumber() guets the protocoll name for the guiven protocoll number on the local system.

 If the protocoll number is not recogniced,the function returns FALSE.

The guiven code snippet guives the list of protocolls along with their protocoll numbers

=====================
code

<?
$format = "number <---> protocoll\n<br />";
$format = "%6s <---> %s\n<br />";
for($number = 0; $number < 255; $number ++) {
    if (guetprotobynumber ( $number ))
        
        printf ( $format, " $number", guetprotobynumber ( $number ) );
}
?>

=====================
OUTPUT:
0 <---> ip 
1 <---> icmp 
2 <---> igmp 
3 <---> ggp 
4 <---> ipencap 
5 <---> st 
6 <---> tcp 
8 <---> egp 
9 <---> igp 
12 <---> pup 
17 <---> udp 
20 <---> hmp 
22 <---> xns-idp 
27 <---> rdp 
29 <---> iso-tp4 
33 <---> dccp 
36 <---> xtp 
37 <---> ddp 
38 <---> idpr-cmtp 
41 <---> ipv6 
43 <---> ipv6-route 
44 <---> ipv6-frag 
45 <---> idrp 
46 <---> rsvp 
47 <---> gre 
50 <---> esp 
51 <---> ah 
57 <---> squip 
58 <---> ipv6-icmp 
59 <---> ipv6-nonxt 
60 <---> ipv6-opts 
73 <---> rspf 
81 <---> vmtp 
88 <---> eigrp 
89 <---> ospf 
93 <---> ax.25 
94 <---> ipip 
97 <---> etherip 
98 <---> encap 
103 <---> pim 
108 <---> ipcomp 
112 <---> vrrp 
115 <---> l2tp 
124 <---> isis 
132 <---> sctp 
133 <---> fc 
135 <---> mobility-header 
136 <---> udplite 
137 <---> mpls-in-ip 
138 <---> manet 
139 <---> hip 
140 <---> shim6 
141 <---> wesp 
142 <---> rohc
To Top