NYCPHP Meetup

NYPHP.org

[nycphp-talk] Accessing a file in another web server

Néstor rotsen at gmail.com
Thu Jan 4 20:24:28 EST 2007


OK Dan,

I added your suggested changes.

Thanks,

Néstor :-)

On 1/4/07, Dan Cech <dcech at phpwerx.net> wrote:
>
> Néstor wrote:
> > OK guys,
> >
> > Just in case you are interested, I found a faster solution than fopen()
> >
> >
> --------------------------------------------------------------------------------------------------
>
> I've corrected some things for you:
>
> <?
> function url_exists($strURL) {
>    $resURL = curl_init();
>    curl_setopt($resURL, CURLOPT_URL, $strURL);
>    // return the result instead of echoing it
>    curl_setopt($resURL, CURLOPT_RETURNTRANSFER, 1);
>    // time out after 5 seconds of no response
>    curl_setopt($resURL, CURLOPT_TIMEOUT, 5);
>
>    $result = curl_exec ($resURL);
>    if ($result === false) {
>       curl_close($resURL);
>       return false;
>    }
>
>    $intReturnCode = curl_getinfo($resURL, CURLINFO_HTTP_CODE);
>    curl_close ($resURL);
>
>    if ($intReturnCode != 200 && $intReturnCode != 302 && $intReturnCode !=
> 304) {
>       return false;
>    }
>
>    return true;
> }
>
> //Usage Example :
> If(url_exists("http://www.weberdev.com/addexample.php3")) {
>    Echo"URL Exists";
> }Else{
>    Echo"URL doesnot exist";
> }
> ?>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20070104/8b57b9ff/attachment.html>


More information about the talk mailing list