WordPress.org

Ready to get started?Download WordPress

Forums

functions.php - what does this code do? (2 posts)

  1. FionaGilbert
    Member
    Posted 4 years ago #

    Hi there,

    I am updating a site for someone and in functions.php I found this code that doesn't appear to do anything. Can anyone tell me it's purpose?

    '
    function get_data($url){
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
    }
    '

    Many thanks,
    Fiona

  2. Gerald
    Member
    Posted 4 years ago #

    This function uses the PHP CURL Library to fetch data from another site..

    A possibly use would be using it to fetch the JSON/XML response from tinyurl.

    It uses the CURL php library. For more information: http://php.net/manual/en/book.curl.php

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags