The getprotobynumber() function is an inbuilt function in PHP which returns the protocol name for a specified protocol number.
string getprotobynumber( int $protocol_number )
Parameters: This function accepts single parameter $protocol_number which is required. It specifies the protocol number, like 6 for tcp, 17 for udp etc.
Return Value: This function returns protocol name on success and FALSE on failure.
Note: This function is available for PHP 4.0.0 and newer version.
Below programs illustrate the getprotobynumber() function in PHP:
Program 1: This program uses protocol number for protocol name “tcp”.
Program 2: This program checking for many protocol name.
6: tcp 17: udp 20: hmp 41: ipv6
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.