判断head返回,如何写? <?php$path = 'http://www.baidu.com/';if(head...==200){ echo "该页面存在!!!"; exit();}?>这代码得如何写? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function checkUrl($url, $curl=false) { $status = '200'; if ($curl) { $ch=curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_NOSIGNAL, TRUE); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_REFERER, $url); //curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.file'); $result = curl_exec($ch); $found = false; if ($result !== false) { $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($statusCode == 200) $found = true; } curl_close($ch); return $found; } else { $tmpArr = get_headers($url,1); if(stripos($tmpArr[0],$status)) return true; } return false; } 由$url = 'http://www.baidu.com/';$h = get_headers($url, true);print_r($h);Array( [0] => HTTP/1.1 200 OK [Date] => Sat, 05 Jan 2013 10:40:59 GMT [Server] => BWS/1.0 [Content-Length] => 9777 [Content-Type] => text/html;charset=gbk [Cache-Control] => private [Expires] => Sat, 05 Jan 2013 10:40:59 GMT [Set-Cookie] => BAIDUID=17B9BC88E615639547C6CB06AEB14F2A:FG=1; expires=Sat, 05-Jan-43 10:40:59 GMT; path=/; domain=.baidu.com [P3P] => CP=" OTI DSP COR IVA OUR IND COM " [Connection] => Close)可知$url = 'http://www.baidu.com/';$h = get_headers($url, true);if(strpos($h[0], '200')) echo 'yes'; 求一正则表达式 为什么中文用urlencode编码后反而在传输中出现乱码 如何存储类里的数据 PHP数组问题 php读取xml数据 WEB项目开发流程问题 php $_GET简单问题 关于文件上传 如果我的会员也用 FCKeditor 编辑器的话,怎么样只显示当前会员上传过的文件呢 由表单输入用户名及密码 然后设成session 从其它页判断这两个变量............ 关于include的变量使用 上传xls文档,其中一个列的值太长,读取到的变成科学计数法,详细见内容
function checkUrl($url, $curl=false)
{
$status = '200';
if ($curl)
{
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_NOSIGNAL, TRUE);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_REFERER, $url);
//curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.file');
$result = curl_exec($ch);
$found = false;
if ($result !== false)
{
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode == 200) $found = true;
}
curl_close($ch); return $found; } else {
$tmpArr = get_headers($url,1);
if(stripos($tmpArr[0],$status)) return true;
}
return false;
}
$h = get_headers($url, true);
print_r($h);Array
(
[0] => HTTP/1.1 200 OK
[Date] => Sat, 05 Jan 2013 10:40:59 GMT
[Server] => BWS/1.0
[Content-Length] => 9777
[Content-Type] => text/html;charset=gbk
[Cache-Control] => private
[Expires] => Sat, 05 Jan 2013 10:40:59 GMT
[Set-Cookie] => BAIDUID=17B9BC88E615639547C6CB06AEB14F2A:FG=1; expires=Sat, 05-Jan-43 10:40:59 GMT; path=/; domain=.baidu.com
[P3P] => CP=" OTI DSP COR IVA OUR IND COM "
[Connection] => Close
)
可知$url = 'http://www.baidu.com/';
$h = get_headers($url, true);
if(strpos($h[0], '200')) echo 'yes';