Tue Oct 28, 2008 2:30 pm
<html>
<head>
<title>Retrieving a Web page using fsockopen()</title>
</head>
<body>
<?php
$host = "www.codemiles.com";
$page = "/index.htm";
$fp = fsockopen( "$host", 80, &$errno, &$errdesc);
if ( ! $fp )
die ( "Couldn't connect to $host:\nError: $errno\nDesc: $errdesc\n" );
$request = "GET $page HTTP/1.0\r\n";
$request .= "Host: $host\r\n";
$request .= "Referer: http://www.codemiles/index.htm\r\n";
$request .= "User-Agent: PHP test client\r\n\r\n";
$page = array();
fputs ( $fp, $request );
while ( ! feof( $fp ) )
$page[] = fgets( $fp, 1024 );
fclose( $fp );print "the server returned ".(count($page))." lines!";
?>
</body>
</html>
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.