Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

HTTP URL error code

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

HTTP URL error code

Postby atomm » Fri Oct 25, 2002 5:49 pm

I'm looking for a way to find out the error code (404, 301, etc.) returned from a web server for any given URL. Say I put in http://www.atommic.com/nonexistant_url. (I already know the server is a valid host and allows http connections.) It should then give me 404 as a result.

I don't know if this is something that should be obvious... I'm relatively new to PHP, but I looked through the documentation, and I couldn't find any good methods aside from using a socket to establish an HTTP connection to do what I need.

Does anyone know a way to do this?

Thanks
atomm
New php-forum User
New php-forum User
 
Posts: 4
Joined: Fri Oct 25, 2002 5:41 pm
Location: /dev/null

Postby Icarus » Fri Oct 25, 2002 10:26 pm

Have a look at the advanced http class at http://lightwood.mirrors.phpclasses.org ... e/576.html

That should get you started
User avatar
Icarus
New php-forum User
New php-forum User
 
Posts: 7
Joined: Thu Oct 24, 2002 9:32 am
Location: Amsterdam, NL

Postby Jay » Fri Oct 25, 2002 10:55 pm

Different OS's will give different outputs, depending on how PHP is compiled. Set up your own custom 404 and use print_r($_SERVER). It'll then list all the server variables and one of them will contain the 404!
Jay
 


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron