Function |
Description |
Instance |
Getmxrr ($hostname, $mxhosts) |
This function is used to recover the MX (mail exchange record) host name for a particular host. Use this function to confirm the mail host for a domain, typically to verify that a mailbox on that domain starts.
|
code: <?php $hosts = Array (); $ret = GETMXRR if ($ret) { print_r ($hosts); } else { echo ' MX retrieval failed '; ?> output: array ( [0] => c10-mail.cnet.com [1] => c12-mail.cnet.com ) |
Gethostbyaddr ($IP) |
This function is used to restore the host name associated with an IP. Use this function to perform an inverse DNS lookup, giving a name to an IP address-such as recording the IP address of your network server log.
|
Code: <?php Echo gethostbyaddr (' 216.239.115.148 '); ?> Output: c10-sha-redirect- Lb.cnet.com
|
gethostbyname ($name) |
This function is inverse with the gethostbyaddr () function and restores the host-related IP address. Use this function to perform a standard DNS lookup and obtain the hostname associated with the IP address-for example, automatically blacklist a suspect domain. |
Code: <?php Echo gethostbyname (' techrepublic.com '); ?> Output: 216.239.115.148 |
p2long ($IP) and Long2ip ($long) |
these functions convert an IP address represented by a number less than 255 from a symbolic connection to an integer or reverse operation. Apply these functions when you need to represent an IP address in an integer format (typically for numeric calculations), or to represent a number format with an IP address. |
code: <?php Echo ip2long (' 216.239.115.148 '); Echo Long2ip (-655395948); ? output: -655395948 216.239.115.148 |
&NBSP;CHECKDNSRR ($host, $type) |
this function checks DNS for $TYPE type records that match the $host host, and returns a Boolean true value if found. The uses this function to check whether a particular DNS record type exists in the host. |
code: <?php $ret = CHECKDNSRR (' Techrepublic.com ', SOA); if ($ret) { echo ' SOA records exist for host '; } else { echo ' SOA records does not exist for host '; ?> output: SOA records exist for host |
dns_get_record ($host, $type) |
This function returns the DNS record of the $host host. The optional $type parameter can only be used to recover those subsets that match a particular type. The uses this function to recover a detailed DNS record for a particular host. |
code: <?php $data = Dns_get_record (' techrepublic.com '); Print_r ($data); ? output: Array ( [0] => Array ( [host] => techrepublic.com [type] => MX [pri] => [target] => c10-mail.cnet.com [class] => in [TTL] => 10756 ) [1] => Array ( [host] => techrepublic.com [type] => NS [target] => ns3.cnet.com [Class] = > in [ttl] => 7885 ) |
Getprotobyname ($num) And Getprotobynum ($name)
|
These functions restore the protocol name and number from the generic system/etc/protocols file. Use these functions to recover system protocol information by name or number. |
Code: <?php Echo Getprotobyname (81); Echo Getprotobyname (' ICMP '); ?>
Output: Vmtp 1
|
Getservbyname ($service, $protocol) |
This function uses the $protocol protocol to recover the port number for the $service service from the generic system/etc/services file. Use this function to automatically obtain port information for running system services. |
Code: <?php echo getservbyname (' http ', ' TCP '); ?> Output: 80 |
Inet_ntop ($ADDR) And Inet_pton ($ADDR) |
These functions convert IP addresses between binary and human-readable addresses. Use this function to convert between the Ipv4/ipv6 address string and the binary expression method.
|
Code: <?php $packed = Inet_pton (' 192.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 log $msg information to the system log device. Use this function to publish a generic system error or warning.
|
Code: <?php Define_syslog_variables (); Openlog (' MyLog ', Log_ndelay, log_local0); Syslog (Log_debug, ' this is A debug message '); Closelog (); ?>
|