Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

How do you know if a browser accepts your cookie? The only way is to send one and test
that it is returned on the next page request.


/
mark this site as being visited
for the next 24 hours
/
setcookie ("HasVisitedLast24Hours", "Yes", time()+86400;
?>


Network I/O


The network I/O functions send information directly over the Internet Protocol, or they
fetch information about Internet hosts.


boolean checkdnsrr(string host, string type)


The checkdnsrr function checks DNS records for a host. The type argument defines the
type of records for which to search. Valid types are listed in Table 8.16.


If type is not specified, checkdnsrr checks for MX records. You may wish to read the
man page for named, the Internet domain name server daemon.


<?
if(checkdnsrr("clearink.com", "MX"))
{
print("clearink.com is a mail exchanger");
}
?>


integer fsockopen(string hostname, integer port, integer
error_number, string error_description, double timeout)


The fsockopen begins a network connection as a file stream, returning a file descriptor
suitable for use by fputs, fgets, and other file-stream functions discussed earlier in this
chapter. A connection is attempted to the hostname at the given port. The hostname may
also be a numerical IP address. The hostname may also be the path to a UNIX domain
socket, in which case port should be set to 0. Some operating systems, specifically
Windows, don't support UNIX domain sockets.


Table 8.16. DNS Record Types
Type Description
Free download pdf