Handle 404 errors php?

Dangerosking

New member
What im trying to do is use the file_get_contents function, and whenever i get a 404 error, "handle it" (or whatever is called in php), and display a message: "invalid query" (or anyother message) instead of the horrible default php message.
This is the error im getting:
Warning: file_get_contents(http://hiscore.runescape.com/index_lite.ws?player=ajgirewng) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not found in /home1/fenixfla/public_html/hiscores.php on line 42

Please note I intent to do this using php only.
I am NOT using the file_get_contents function to handle the 404 error, it is just a function in my code.
I am not using local associate paths beacause I am obtainning the values of some of the variables by parsing a external website.
I repeat, I intent to do this using php ONLY no other files.

What I am basically trying to do here is somehow tell if a external website page returns a 404 error or not and output a simple message if it does.
 
Back
Top