1

I am using Curl for the first time in PHP. Here is my code.

<?php
    function curl($url){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        $data = curl_exec($ch);
        echo curl_getinfo($ch) . '<br/>';   //returns "Array"
        curl_errno($ch) . '<br/>';    // returns "7"
        curl_error($ch) . '<br/>';    //returns "Failed connect to www.epcc.ed.ac.uk:80; No error"
        curl_close($ch);
        return $data;
        }


        $url = 'http://www.epcc.ed.ac.uk/education-training/general-training/upcoming-courses-and-events/';
        $output = curl($url);
        var_dump($output);  // returns "bool(false)"
?>

I have added the output what I get in comments in the code.

Can anyone tell me where is the problem? Is it a general issue or any proxy issue.

Thanks

user3365207
  • 235
  • 6
  • 18

1 Answers1

2

It appears to be a proxy issue, as you suspected. If you connect to your network via a proxy, this will need to be set-up for curl.

This may help -> Use Curl via Proxy.

Community
  • 1
  • 1
user2798227
  • 853
  • 1
  • 16
  • 31