Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2005
    Posts
    252
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Will this curl snippet work with most web host php configs?

    PHP Code:
    if(!file_exists($file) || filemtime($file) < time() - 3600
            {
                
    $ch curl_init('http://www.mydomain.com/rss?p=' urlencode($rpl) . '&u=' urlencode($units['date']));
                @
    curl_setopt($chCURLOPT_HEADER0);
                
    //@curl_setopt($ch, CURLOPT_MUTE, 1);
                
    @curl_setopt($chCURLOPT_RETURNTRANSFER1);
                
    $str = @curl_exec($ch);
                @
    curl_close($ch);
                
    $fp = @fopen($file,'w');
                @
    fwrite($fp,$str);
                @
    fclose($fp);
            }
                
            
    $this->data = @file_get_contents($file); 
    I'm creating a version of this script that does not use fopen. Can someone please help modify?

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Sure.. if they have CURL installed. If you have PHP 5(you can find versions for PHP 4 too) you will be able to use file_put_contents() instead of fopen(), fwrite(), and fclose(). Your error catching is pretty lacking. Are you taking into account that any or all of that could fail and you you not know why?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •