function Purpose: Gets the Remote Web page content of the specified server when the same domain name corresponds to multiple IPs

Source: Internet
Author: User


<?php

/************************
*
function Purpose: Gets the Remote Web page content of the specified server when the same domain name corresponds to multiple IPs
* Date Created: 2008-12-09
* Created by: Zhang Yi (img.jb51.net)

* Parameter Description:
* $ip The IP address of the server
* The host name of the $host server
* The URL address of the $url server (excluding domain name)

* Return value:
* Access to the Remote Web page content
* False access to Remote Web page failed
************************/

function Httpvisit ($ip, $host, $url)
{
$errstr = ";
$errno =
‘‘;
$fp = Fsockopen ($ip, $errno, $errstr, 90);
if (! $fp)
{

return false;
}
Else
{
$out = "GET {$url} http/1.1\r\n";

$out. = "host:{$host}\r\n";
$out. = "connection:close\r\n\r\n";

Fputs ($fp, $out);

while ($line = Fread ($fp, 4096)) {
$response. =
$line;
}
Fclose ($FP);

Remove header information
$pos =
Strpos ($response, "\r\n\r\n");
$response = substr ($response, $pos + 4);


return $response;
}
}

Call Method:
$server _info1 =
Httpvisit ("72.249.146.213", "img.jb51.net", "/abc.php");
$server _info2 =
Httpvisit ("72.249.146.214", "img.jb51.net", "/abc.php");
$server _info3 =
Httpvisit ("72.249.146.215", "img.jb51.net", "/abc.php");
?>

function Purpose: Gets the Remote Web page content of the specified server when the same domain name corresponds to multiple IPs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.