Chapter 10 Review:

• How do you use fopen() to access another Web site? What restrictions exist when you do so? (See page 328.)

Use a $url variable inside fopen() with type of connection modifier, ie $handle = fopen($url,'mode'), opens a file pointer/resource handle that can be fread() and displayed anywhere. Two things to remember: 1: use a trailing slash (although local testing reveals in does find ch8/index.php from /ch8??). 2: Some php installations may not support remote read.

• What are sockets? What is a port? What PHP function do you use to communicate over sockets? (See page 333.)

Sockets are the primary connection vehicles of the internet and are defined as the endpoint between these connections. A port is a specific door/hallway you pass the data through. The PHP function fsockopen() will allow establishment of these connections.

• What are HTTP status codes? (See page 334.)

Status codes are the responses from a server from and HTTP request that is the basis for all website retrieval. The most commonly seen of these if 404, indicating the page cannot be found.

• What does the parse_url() function do? (See page 333.)

Parse_url(), breaks a url into an array of component pieces as follows: scheme (http), host, path, data.

• What does the set_time_limit() function do? Why is it necessary in the check_urls.php script? (See page 337.)

The function set_time_lmit() will define the max amount of time to process the script that the page containing the function is run. Interestingly, setting to 0, makes it unlimited. In the locally defined check_urls funciton, this keeps an endless hang when parsing and gathering data from a remote host.

• In what variable will PHP store a user’s IP address? (See page 339.)

$_SERVER['REMOTE_ADDR'].

• What PHP function can be used to find the IP address associated with a domain name? (See page 339.)

gethostbyname(ip)

• What is cURL? What kinds of things can it be used for? (See page 343.)

cURL is short for Client URLs. It is a library of tools for accessing, and retrieving info over networks.

• What are Web services? How does a PHP script used as a Web service, as opposed to an HTML page, differ? (See page 347.)

Web services is the broad term applied to information exchange between computers of the internet. The difference between a PHP script retrieving versus an html page call is that the php script emulates only the parts of an http request needed to access information according to a proscribed schema.