12月 062010
 

接口:http://xxx.yyy.cn/a.php
线上地址: xxx.yyy.cn => 60.6.6.6
测试地址: xxx.yyy.cn => 10.6.6.6。
现在为了测试,你需要从A机器上访问10.6.6.6,而且你没有权限修改A机器的host文件

办法一:
<?php
$opts 
= array('http' => array( 'header'  => 'Host: xxx.yyy.cn',));
$context  stream_context_create($opts);
$result file_get_contents('http://10.6.6.6/a.php'false$context);
echo 
$result;
?>

办法二:
自己使用fsockopen函数来实现http请求,其实还是修改http的host头域

办法三:
使用curl来设置host头域

应该还有更多办法,这里不再讨论,没意思

 Posted by at 下午 11:17

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据