Re: [FAQ] How do I retrieve a page from a web site? (Was: PHP behaving like a user using a browser)
- From: Michał Woźniak <mikiwoz_remove_this@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Apr 2005 08:40:57 +0200
Great thing, but it misses an issue:
Suppose I have a file, let's call it incl.php, that I include in my
scripts, but I don't want to be accessible directly - when somebody
tries http://my.server/incl.php, though the file is actually there, I
want to display the webserver's 404 Error default message. I don't want
it to be hardcoded, though (like
$err404='<HTML><BODY>...</BODY></HTML>';), in other words I'd like to do
something like:
$err404=file_ge_contents('http://localhost/foobar.htm'); # foobar.htm
does not exist
$err404=str_replace('http://localhost/foobar.htm', __FILE__, $err404);
echp $err404;
die();
But - file_get_contents returns noting and an error:
Warning: file_get_contents(http://localhost/no_such_file.php): failed to
open stream: HTTP request failed! HTTP/1.1 404 Not Found in blahblah.php
on line 666.
what shuld I do to get the err404 page? Besides CURL, there must be
another way. :)
TIA
Mike
.
- Follow-Ups:
- Re: How do I retrieve a page from a web site? (Was: PHP behaving like a user using a browser)
- From: R. Rajesh Jeba Anbiah
- Re: How do I retrieve a page from a web site? (Was: PHP behaving like a user using a browser)
- References:
- PHP behaving like a user using a browser
- From: David Rasmussen
- Re: PHP behaving like a user using a browser
- From: R. Rajesh Jeba Anbiah
- Re: [FAQ] PHP behaving like a user using a browser
- From: Chung Leong
- Re: [FAQ] How do I retrieve a page from a web site? (Was: PHP behaving like a user using a browser)
- From: R. Rajesh Jeba Anbiah
- PHP behaving like a user using a browser
- Prev by Date: Re: reordering list help or algo needed
- Next by Date: Re: PERL or PHP for a regular console application?
- Previous by thread: Re: [FAQ] How do I retrieve a page from a web site? (Was: PHP behaving like a user using a browser)
- Next by thread: Re: How do I retrieve a page from a web site? (Was: PHP behaving like a user using a browser)
- Index(es):
Relevant Pages
|