Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

Retrieving a Web Page Using fsockopen()

Tue Oct 28, 2008 2:30 pm

Code:
<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>




Post a reply
  Related Posts  to : Retrieving a Web Page Using fsockopen()
 Image Scroller-scrollbar-LINE_UP,LINE_DOWN-PAGE-UP-PAGE-DOWN     -  
 How to add CSS to a web page     -  
 jsp page counter     -  
 redirect to another page     -  
 Page Call MySelf PHP     -  
 Registration page in jsp     -  
 add image row in your web page     -  
 go to previous page using JavaScript     -  
 Create Web Page using Photoshop     -  
 Getting Forums to appear on home page     -  

Topic Tags

PHP Networking