Re: Why not 'file_exists()' for URLs?
| From: | Yasuo Ohgaki | Date: | Tue, 20 Mar 2001 11:02:50 +0000 |
| Subject: | Re: Why not 'file_exists()' for URLs? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-44717@lists.php.net to get a copy of this message | ||
[Since original poster requests for procedure for feature/change request.]
You can use bug reporting system to request new feature or changes.
http://www.php.net/bugs.php
Use "Feature/Change Request" as "Type of bug".
It will be sent to php-dev mail list and stored as feature/change request in db.
Regards,
--
Yasuo Ohgaki
"Mike" <pallmall@hushmail.com> wrote in message news:1103_985083470@matthew...
> On 19 Mar 2001 06:53:00 -0800, david@davidgunter.com ("David G.") wrote:
> > Since fopen/fread/fclose all work with standard URLs, why not allow
> > file_exists() to work with URLs as well?
> > What is the procedure to make such a request?
>
>
> Try this:
>
> function url_exist($url) {
> $url_parts = parse_url($url);
> $fp = fsockopen($url_parts["host"], 80);
> if (!$fp) return false;
> $path = $url_parts["path")?$url_parts["path"]:"/";
> fwrite($fp, "GET $path HTTP/1.0\r\n\r\n");
> $response = fgets($fp, 500);
> preg_match("/^HTTP\/\d\.\d[ \t]+(\d+)[ \t]*([^\r]*)/", $response, $matches);
> switch ($matches[1]) {
> case 404: // HTTP error not found
> return false;
> case 200: // HTTP OK
> return true;
> default:
> return false; // other responses probably counts false
> }
> }
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>