Is bookmark a valid link?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<?php

function getHeader($url)
{
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, 		$url);
	curl_setopt($ch, CURLOPT_HEADER, 	1);
	curl_setopt($ch, CURLOPT_TIMEOUT,	2);
	curl_setopt($ch, CURLOPT_NOBODY,	1);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	
	return curl_exec($ch);
}

echo getHeader('http://forums.devnetwork.net');

?>
outputs

Code: Select all

HTTP/1.1 200 OK
Date: Sat, 07 Aug 2004 17:32:24 GMT
Server: Apache/1.3.31 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.8 FrontPage/5.0.2.2634a mod_ssl/2.8.18 OpenSSL/0.9.7a
X-Powered-By: PHP/4.3.8
Set-Cookie: phpbb2mysql_data=s%3A0%3A%22%22%3B; expires=Sun, 07-Aug-05 17:32:24 GMT; path=/; domain=devnetwork.net
Set-Cookie: phpbb2mysql_sid=61b110b6461ddb7e728c7d4f692b1da6; path=/; domain=devnetwork.net
Cache-Control: private, pre-check=0, post-check=0, max-age=0
Expires: Sat, 07 Aug 2004 17:32:24 GMT
Last-Modified: Sat, 07 Aug 2004 17:32:24 GMT
Content-Type: text/html
You want the success codes: HTTP/1.X 2XX, HTTP/1.X 3XX

300's are redirections.. so you may need to look where they want to send you.. :)
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Feyd you rock. Thanks.
Post Reply