Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • CURL Fails To Load Page

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 13
    Answer it

    Php Guys,

    Why does this cURL show complete blank page ?

     

    <?php
     
    /*
    ERROR HANDLING
    */
    declare(strict_types=1);
    ini_set('display_errors', '1');
    ini_set('display_startup_errors', '1');
    error_reporting(E_ALL);
    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
     
        function curl_download($Url){
      // is cURL installed yet?
      if (!function_exists('curl_init')){
        die('Sorry cURL is not installed!');
      }
      
      $Url = "http://findnerd.com";
     
      // OK cool - then let's create a new cURL resource handle
      $ch = curl_init();
     
      // Now set some options (most are optional)
     
      // Set URL to download
      curl_setopt($ch, CURLOPT_URL, $Url);
     
      // User agent
      curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
     
      // Include header in result? (0 = yes, 1 = no)
      curl_setopt($ch, CURLOPT_HEADER, 0);
     
      // Should cURL return or print out the data? (true = retu rn, false = print)
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     
      // Timeout in seconds
      curl_setopt($ch, CURLOPT_TIMEOUT, 10);
     
      // Download the given URL, and return output
      $output = curl_exec($ch);
     
      // Close the cURL resource, and free system resources
      curl_close($ch);
     
      return $output;
    }
     
    ?>

     

 1 Answer(s)

  • Hello Sir,

    As per my understanding you made a function to hit the findnerd but you didn't call this function. Kindly call this function like below.
     
    echo curl_download('http:google.com');
     
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: