Pejman Moghadam / Scripts

php CURL example

Public domain


<?php

        // Show latest kernel version

        // create curl resource
        $ch = curl_init();

        // set url
        curl_setopt($ch, CURLOPT_URL, "http://www.kernel.org/pub/linux/kernel/v2.6/");

        //return the transfer as a string
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        // $output contains the output string
        $output = curl_exec($ch);

        // close curl resource to free up system resources
        curl_close($ch);     

        $output=strstr($output,"LATEST-IS");
        echo substr($output,0,strpos($output,"\""));
?>

BY: Pejman Moghadam
TAG: php, curl
DATE: 2010-09-24 18:59:47


Pejman Moghadam / Scripts [ TXT ]