Outputting the Status Lines Returned by Web Servers
<html> <head> <title>Outputting the status lines returned by web servers</title> </head> <body> <?php $to_check = array ("www.java2s.com" => "/index.htm"); foreach ( $to_check as $host => $page ){ $fp = fsockopen( "$host", 80, &$errno, &$errdesc, 10); print "Trying $host<BR>\n"; if ( ! $fp ){ print "Couldn't connect to $host:\n<br>Error: $errno\n<br>Desc:$errdesc\n"; print "<br><hr><br>\n"; continue; } print "Trying to get $page<br>\n"; fputs( $fp, "HEAD $page HTTP/1.0\r\n\r\n" ); print fgets( $fp, 1024 ); print "<br><br><br>\n"; fclose( $fp ); } ?> </body> </html>
1. | Open socket and read | ||
2. | Getting and Printing a Web Page with fopen() | ||
3. | Retrieving a Web Page Using fsockopen() |