<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>白舟工作室 &#187; 函数</title>
	<atom:link href="http://www.baizoo.cn/tag/%e5%87%bd%e6%95%b0/feed" rel="self" type="application/rss+xml" />
	<link>http://www.baizoo.cn</link>
	<description>——长风破浪会有时</description>
	<lastBuildDate>Mon, 30 Jan 2012 08:09:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Get_headers判断远程文件是否存在-PHP</title>
		<link>http://www.baizoo.cn/archives/469.html</link>
		<comments>http://www.baizoo.cn/archives/469.html#comments</comments>
		<pubDate>Thu, 09 Apr 2009 12:53:19 +0000</pubDate>
		<dc:creator>baizoo</dc:creator>
				<category><![CDATA[技术爱好]]></category>
		<category><![CDATA[get_headers]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[函数]]></category>

		<guid isPermaLink="false">http://www.baizoo.cn/?p=469</guid>
		<description><![CDATA[判断网页文件是否存在的方法倒是很多，asp版的可以看我前两篇文章介绍的方法，FSO方法和XMLHTTP方法,这里有一个php版的，摘录并了解一下get_headers函数。 补充说明： get_headers函数说明：取得服务器响应一个HTTP 请求所发送的所有标头 array get_headers ( string $url [, int $format ] ) get_headers() 返回一个数组，包含有服务器响应一个 HTTP 请求所发送的标头。如果失败则返回 FALSE 并发出一条 E_WARNING 级别的错误信息。 如果将可选的 format 参数设为 1，则 get_headers() 会解析相应的信息并设定数组的键名。 举例：get_headers()函数使用例子 上例的输出类似于： Array ( [0] => HTTP/1.1 200 OK [1] => Date: Sat, 29 May 2004 12:28:13 GMT [2] => Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) [3] => Last-Modified: [...]]]></description>
			<content:encoded><![CDATA[<p>判断网页文件是否存在的方法倒是很多，asp版的可以看我前两篇文章介绍的方法，<a href="http://www.baizoo.cn/archives/465.html">FSO方法</a>和<a href="http://www.baizoo.cn/archives/454.html">XMLHTTP方法</a>,这里有一个php版的，摘录并了解一下get_headers函数。<br />
<coolcode linenum="off" lang="php"><br />
<?php<br />
$url = 'http://www.baizoo.cn/index.php';<br />
if (get_headers($url)<>false)<br />
{<br />
   echo &#8220;文件存在&#8221;;<br />
}<br />
 else<br />
 {<br />
   echo &#8220;文件不存在&#8221;;<br />
 }<br />
//print_r(get_headers($url, 1));<br />
?><br />
</coolcode></p>
<p>补充说明：<br />
get_headers函数说明：取得服务器响应一个HTTP 请求所发送的所有标头</p>
<p>array get_headers ( string $url [, int $format ] )</p>
<p>get_headers() 返回一个数组，包含有服务器响应一个 HTTP 请求所发送的标头。如果失败则返回 FALSE 并发出一条 E_WARNING 级别的错误信息。<span id="more-469"></span></p>
<p>如果将可选的 format 参数设为 1，则 get_headers() 会解析相应的信息并设定数组的键名。<br />
举例：get_headers()函数使用例子<br />
<?php<br />
$url = 'http://www.example.com';</p>
<p>print_r(get_headers($url));</p>
<p>print_r(get_headers($url, 1));<br />
?><br />
上例的输出类似于：<br />
Array<br />
(<br />
    [0] => HTTP/1.1 200 OK<br />
    [1] => Date: Sat, 29 May 2004 12:28:13 GMT<br />
    [2] => Server: Apache/1.3.27 (Unix)  (Red-Hat/Linux)<br />
    [3] => Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT<br />
    [4] => ETag: &#8220;3f80f-1b6-3e1cb03b&#8221;<br />
    [5] => Accept-Ranges: bytes<br />
    [6] => Content-Length: 438<br />
    [7] => Connection: close<br />
    [8] => Content-Type: text/html<br />
)</p>
<p>Array<br />
(<br />
    [0] => HTTP/1.1 200 OK<br />
    [Date] => Sat, 29 May 2004 12:28:14 GMT<br />
    [Server] => Apache/1.3.27 (Unix)  (Red-Hat/Linux)<br />
    [Last-Modified] => Wed, 08 Jan 2003 23:11:55 GMT<br />
    [ETag] => &#8220;3f80f-1b6-3e1cb03b&#8221;<br />
    [Accept-Ranges] => bytes<br />
    [Content-Length] => 438<br />
    [Connection] => close<br />
    [Content-Type] => text/html<br />
)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.baizoo.cn/archives/469.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

