HTTP URL error code

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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

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 (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?


User avatar
New php-forum User
New php-forum User
Posts: 7
Joined: Thu Oct 24, 2002 9:32 am
Location: Amsterdam, NL

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

Have a look at the advanced http class at ... e/576.html

That should get you started


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!

Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot] and 5 guests