By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,748 Members | 1,451 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,748 IT Pros & Developers. It's quick & easy.

Using CURL to get the HTTP status code of a URL

P: n/a
I would like to get the HTTP status code of a URL using PHP. I think
CURL is the way to go but I can't see how to do it. I see I can use
curl_getinfo on the CURL session after I've curl_exec'ed it but I
can't see what options I should set to get CURL to only get the HTTP
status code and not retrieve the data at the URL.

Help gratefully received!

Thanks,
Geoff
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

On 29 Mar 2004 03:26:11 -0800, ge*****************@alphaworks.co.uk
(Geoff Soper) wrote:
I would like to get the HTTP status code of a URL using PHP. I think
CURL is the way to go but I can't see how to do it. I see I can use
curl_getinfo on the CURL session after I've curl_exec'ed it but I
can't see what options I should set to get CURL to only get the HTTP
status code and not retrieve the data at the URL.

I think you want to send a HEAD request.

www.php.net/curl has heaps of examples, a HEAD request has IMO the
same structure as a GET request.

HTH, Jochen
--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #2

P: n/a
Hello,

On 29 Mar 2004 03:26:11 -0800, ge*****************@alphaworks.co.uk
(Geoff Soper) wrote:
I would like to get the HTTP status code of a URL using PHP. I think
CURL is the way to go but I can't see how to do it. I see I can use
curl_getinfo on the CURL session after I've curl_exec'ed it but I
can't see what options I should set to get CURL to only get the HTTP
status code and not retrieve the data at the URL.


You may want to try this HTTP client class that lets you do exactly what
you want.

http://www.phpclasses.org/httpclient

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.