当我尝试打开连接HTTP_Request
时抛出:
反应不当:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
仅当站点与脚本位于同一服务器上时。
有谁知道为什么会这样或者如何修复它?
<?php
require_once 'HTTP/Request2.php';
$hosts = array('http://example.com', 'http://site_on_my_vps.com' );
$status = array();
foreach($hosts as $host){
$request = new HTTP_Request2( $host , HTTP_Request2::METHOD_GET);
$status[ $host ] = array( );
try {
$response = $request->send();
$rbody = $request->getBody();
$status[ $host ]['status']= $response->getStatus();
$status[ $host ]['bodysize']=strlen( $rbody );
} catch (HTTP_Request2_Exception $e) {
$status[ $host ]['error'] = $e->getMessage();
}
}
print_r($status);
upd:添加代码