Recent Posts
- 10 Things To Do When Launching A Site
- Using PHP to connect to SFTP
- Asynchronous Virtual Pageviews with Google Analytics
- 5 Advanced Text Editing Keyboard Shortcuts
- Get the headers of a HTTP request with PHP
- How-to: Create PDF preview images in PHP – Part 2
- How-to: Create PDF preview images in PHP
- Quick Code: Get the domain name in JS
- Things to think about when designing a logo
- Javascript Array Functions
Topics
ImageXY
ImageXY - Mac OS X Batch Photo Resizer

Quickly and painlessly bulk resize images, change image formats and create web-friendly photos for your website.
Available on the Mac App Store!
Get the headers of a HTTP request with PHP
Need to check that a URL is valid? Or get the last-modified date, or the charset, or the ETag of a page? Here is a simple bit of code to help you do just that by returning the headers of a HTTP request for you.
The following PHP code is the equivalent of ‘curl -I‘:
<?php
$strURL = "webvamp.co.uk";
$resCurl = curl_init();
//set URL and other appropriate options
curl_setopt($resCurl, CURLOPT_URL, $strURL);
curl_setopt($resCurl, CURLOPT_HEADER, true);
curl_setopt($resCurl, CURLOPT_NOBODY, true);
curl_setopt($resCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($resCurl, CURLOPT_FOLLOWLOCATION, true);
//get the headers
$strHeaders = curl_exec($resCurl);
//close cURL
curl_close($resCurl);
echo $strHeaders;
?>
You will of course need the cURL library compiled with PHP.