<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[张宴的博客]]></title> 
<link>http://zyan.cc/index.php</link> 
<description><![CDATA[Web系统架构与底层研发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[张宴的博客]]></copyright>
<item>
<link>http://zyan.cc/post/389/</link>
<title><![CDATA[同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>张宴 &lt;net@s135.com&gt;</author>
<category><![CDATA[PHP/JS/Shell]]></category>
<pubDate>Sun, 14 Dec 2008 16:01:32 +0000</pubDate> 
<guid>http://zyan.cc/post/389/</guid> 
<description>
<![CDATA[ 
	　　[文章作者：张宴 本文版本：v1.0 最后修改：2008.12.15 转载请注明原文链接：<a href="http://blog.zyan.cc/post/389/" target="_blank">http://blog.zyan.cc/post/389/</a>]<br/><br/>　　PHP获取远程网页内容有多种方式，例如用自带的file_get_contents、fopen等函数。<div class="quote"><div class="quote-title">引用</div><div class="quote-content">&lt;?php&nbsp;&nbsp; <br/>echo file_get_contents(&quot;<a href="http://blog.zyan.cc/abc.php&quot;);&nbsp;&nbsp;" target="_blank">http://blog.zyan.cc/abc.php&quot;);&nbsp;&nbsp;</a> <br/>?&gt;</div></div><br/>　　但是，在DNS轮询等负载均衡中，同一域名，可能对应多台服务器，多个IP。假设blog.zyan.cc被DNS解析到72.249.146.213、72.249.146.214、72.249.146.215三个IP，用户每次访问blog.zyan.cc，系统会根据负载均衡的相应算法访问其中的一台服务器。<br/><br/>　　上周做一个视频项目时，就碰到这样一类需求：需要依次访问每台服务器上的一个PHP接口程序（假设为abc.php），查询这台服务器的传输状态。<br/><br/>　　这时就不能直接用file_get_contents访问<a href="http://blog.zyan.cc/abc.php" target="_blank">http://blog.zyan.cc/abc.php</a>了，因为它可能一直重复访问某一台服务器。<br/><br/>　　而采用依次访问<a href="http://72.249.146.213/abc.php" target="_blank">http://72.249.146.213/abc.php</a>、<a href="http://72.249.146.214/abc.php" target="_blank">http://72.249.146.214/abc.php</a>、<a href="http://72.249.146.215/abc.php" target="_blank">http://72.249.146.215/abc.php</a>的方法，在这三台服务器上的Web Server配有多个虚拟主机时，也是不行的。<br/><br/>　　通过设置本地hosts也不行，因为hosts不能设置多个IP对应同一个域名。<br/><br/>　　那就只有通过PHP和HTTP协议来实现：访问abc.php时，在header头中加上blog.zyan.cc域名。于是，我写了下面这个PHP函数：<br/>............<br/><br/>Tags - <a href="http://zyan.cc/tags/php/" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment2251</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>xk &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 15 Dec 2008 00:43:45 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment2251</guid> 
<description>
<![CDATA[ 
	沙发.
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment2255</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>Bendy &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 15 Dec 2008 09:33:39 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment2255</guid> 
<description>
<![CDATA[ 
	呵..这个比较简单.但可能会很实用...
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment2256</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>FinalBSD &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 15 Dec 2008 09:57:22 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment2256</guid> 
<description>
<![CDATA[ 
	干脆再封装一下，使用gethostbynamel获得这个域名对应的所有IP地址，然后直接用域名调用如何？省的一个个指定IP地址。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment2257</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>itloveboy &lt;ccitnet@126.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 15 Dec 2008 10:49:21 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment2257</guid> 
<description>
<![CDATA[ 
	张宴您好！<br/>看了你得很多的文章，学习了很多的知识，首先我向你表示感谢，：）<br/>我看过你的一篇关于 中南民族大学 PHPWIND论坛设计的文章，我在去年也是跟你做得实名认证差不多，但是我的程序还有很多的不足，最重要的也是我想向您请教的，就是关于数据和程序加密的，我看了你的展示里面把学生的和老师的个人数据都加密了，而且把程序也加密了，我想知道这是怎么做到的，如果方便的话，就告诉我一下吧，期待您的回答！
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment2274</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>peter &lt;cuipeng99@hotmai.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 18 Dec 2008 20:29:18 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment2274</guid> 
<description>
<![CDATA[ 
	感谢博主～
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment2282</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>jk &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 20 Dec 2008 08:18:52 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment2282</guid> 
<description>
<![CDATA[ 
	这个请求的时候要用HTTP/1.0吧～
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment2309</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>玉面修罗 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 24 Dec 2008 03:14:53 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment2309</guid> 
<description>
<![CDATA[ 
	可以封装一下..<br/>PHP能并发执行这类任务..<br/>特别是当主机数量庞大的时候,并发执行的效率高很多.
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment2327</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>不羁的风 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 27 Dec 2008 04:51:41 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment2327</guid> 
<description>
<![CDATA[ 
	很享受
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment2441</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>稳压器 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 19 Jan 2009 07:00:03 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment2441</guid> 
<description>
<![CDATA[ 
	不错 支持<br/><br/><br/><br/><br/><br/><br/><br/><br/><a href="http://www.wuchenwenyaqi.com/cpzs.asp" target="_blank">稳压器</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment2991</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>域名 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 10 Apr 2009 06:24:47 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment2991</guid> 
<description>
<![CDATA[ 
	这个满实用的，我收藏了··
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment2992</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>crystal &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 10 Apr 2009 06:25:52 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment2992</guid> 
<description>
<![CDATA[ 
	这应该是楼主的经验总结的··很不错噢··
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment2993</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>鱼儿 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 10 Apr 2009 06:27:00 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment2993</guid> 
<description>
<![CDATA[ 
	原来楼主叫张宴···哈哈 好新颖的名字·
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment3093</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>cykzl &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 23 Apr 2009 03:22:18 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment3093</guid> 
<description>
<![CDATA[ 
	博主才毕业两年，有这样的成就佩服、、、、、
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment4039</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>图书批发 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 16 Sep 2009 01:56:56 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment4039</guid> 
<description>
<![CDATA[ 
	学习一下，研究研究。--<a href="http://www.buyshu.com/" target="_blank">图书批发</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/389/#blogcomment4953</link>
<title><![CDATA[[评论] 同一域名对应多个IP时，PHP获取远程网页内容的函数[原创]]]></title> 
<author>sinopower &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 05 Feb 2010 08:38:17 +0000</pubDate> 
<guid>http://zyan.cc/post/389/#blogcomment4953</guid> 
<description>
<![CDATA[ 
	dig +short 解析出来，cname不行
]]>
</description>
</item>
</channel>
</rss>