Skip to content

Instantly share code, notes, and snippets.

@squiter
Created June 13, 2011 20:59
Show Gist options
  • Save squiter/1023682 to your computer and use it in GitHub Desktop.
Save squiter/1023682 to your computer and use it in GitHub Desktop.
Get http response code from a URL
<?php
/*
* Check HTTP Header Response
* Author: Brunno dos Santos
* Version: 1.0
* Usage: run php check_http.php www.yoursite.com
*/
$ch = curl_init($argv[1]);
curl_setopt($ch, CURLOPT_NOBODY, 1);
$c = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE)."\n\r";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment