Function |
Description |
Instance |
Getmxrr ($ Hostname, $ Mxhosts) |
This function is used to restore the MX (mail exchange record) host name of a specific host. Use this function to confirm the email host of a domain, usually starting with verifying a mailbox in that domain. |
Code: $ Hosts = array (); $ Ret = getmxrr ('Techrepublic. com', $ hosts ); If ($ ret ){ Print_r ($ hosts ); } Else { Echo 'MX retrieval failed '; } ?> Output: Array ( C10-mail.cnet.com C12-mail.cnet.com ) |
Gethostbyaddr ($ Ip) |
This function is used to restore the host name related to an IP address. Use this function to perform a reverse DNS lookup and assign a name to an IP address, for example, the IP address that records your network server logs.
|
Code: Echo gethostbyaddr ('1970. 239.115.148 '); ?> Output: C10-sha-redirect- Lb.cnet.com |
Gethostbyname ($ Name) |
This function is opposite to the gethostbyaddr () function to restore the IP address related to the host. Use this function to perform a standard DNS lookup to obtain the host name related to the IP address-for example, when the suspicious domain is automatically blacklisted. |
Code: Echo gethostbyname ('Techrepublic. com '); ?> Output: 216.239.115.148 |
P2long ($ ip) And Long2ip ($ long) |
These functions convert the IP addresses represented by four numbers less than 255 connected by the symbol into integers or perform inverse operations. These functions are used when you need to express IP addresses in integer format (usually used for digital computing) or use IP addresses to represent digital formats. |
Code: Echo ip2long ('1970. 239.115.148 '); Echo long2ip (-655395948 ); ?> Output: -655395948 216.239.115.148 |
Checkdnsrr ($ Host, $ type) |
This function checks the $ type record that matches the $ host in DNS. if found, the Boolean true value is returned. Use this function to check whether a specific DNS record type exists in the host. |
Code: $ Ret = checkdnsrr ('Techrepublic. com', SOA ); If ($ ret ){ Echo 'soa records Exist for host '; } Else { Echo 'soa records do Not exist for host '; } ?> Output: SOA records exist for host |
Dns_get_record ($ Host, $ type) |
This function returns the DNS record of the $ host. The optional $ type parameter can only be used to restore subsets that match a specific type. Use this function to restore detailed DNS records of a special host. |
Code: $ Data = dns_get_record ('Techrepublic. com '); Print_r ($ data ); ?> Output: Array ( [0] => Array ( [Host] => Techrepublic.com [Type] => MX [Pri] = & gt; 500 [Target] => C10-mail.cnet.com [Class] => IN [Ttl] = & gt; 10756 ) [1] => Array ( [Host] => Techrepublic.com [Type] => NS [Target] => Ns3.cnet.com [Class] => IN [Ttl] = & gt; 7885 ) ) |
Getprotobyname ($ Num) And Getprotobynum ($ Name)
|
These functions restore the protocol name and number from the/etc/protocols file of the pan system. Use these functions to restore system protocol information by name or number. |
Code: Echo getprotobyname (81 ); Echo getprotobyname ('Icmp '); ?> Output: Vmtp 1 |
Getservbyname ($ Service, $ Protocol) |
This function uses the $ protocol to restore the port number of $ service from the/etc/services file of the pan system. Use this function to automatically obtain the port information for running system services. |
Code: Echo getservbyname ('http ', 'Tcp '); ?> Output: 80 |
Inet_ntop ($ Addr) And Inet_pton ($ Addr) |
These functions convert IP addresses between binary and readable addresses. Use this function to convert Ipv4/Ipv6 address strings to binary expressions.
|
Code: $ Packed = inet_pton ('1970. 168.0.1 '); $ Unpacked = inet_ntop ($ Packed ); Echo $ unpacked; ?> Output: 192.168.0.1 |
Syslog ($ Level, $ msg) |
This function uses the warning level $ level to record $ msg information to the system log device. Use this function to publish a wildcard system error or warning.
|
Code: Define_syslog_variables (); Openlog ('mylog ', LOG_NDELAY, LOG_LOCAL0 ); Syslog (LOG_DEBUG, 'This is A debug message '); Closelog (); ?>
|