+ Post New Thread
Results 1 to 7 of 7

Thread: what is curl in php example

  1. #1
    Junior Member vikas Industries's Avatar
    Join Date
    May 2015
    Location
    F-76-77, Phase – VII, Focal Point, Ludhiana – 141 010. (Pb.) INDIA
    Posts
    12

    what is curl in php example

    what is curl in php example

  2. #2
    Junior Member techpro's Avatar
    Join Date
    Jan 2016
    Posts
    17


    Is this useful / helpfull? Yes | No
    cURL is a way you can hit a URL from your code to get a html response from it. cURl library enable to make Http requests in PHP and to use cURL function in PHP install libcurl package (For PHP 4.2.3, Install libcurl version 7.9.0 or higher | For PHP 4.3.0 install libcurl version 7.9.8 or higher | For PHP 5.0.0 install libcurl version 7.9.8 or higher)

    Learn more at http://php.net/manual/en/book.curl.php

  3. #3


    Is this useful / helpfull? Yes | No
    cURL is a library that gives you a chance to make HTTP asks for in PHP. All that you have to think about it (and most different expansions) can be found in the PHP manual. Keeping in mind the end goal to utilize PHP's cURL capacities you have to introduce the » libcurl bundle. PHP requires that you utilize libcurl 7.0.2-beta or higher.

  4. #4


    Is this useful / helpfull? Yes | No
    A command line tool for getting or sending files using URL syntax.

  5. #5
    Junior Member jackwilliam's Avatar
    Join Date
    Jul 2017
    Location
    india
    Posts
    7


    Is this useful / helpfull? Yes | No
    PHP Curl tutorial with example. In this tutorial we will explore what is curl, how to use curl in php. Tutorial is for beginner to advance.

  6. #6


    Is this useful / helpfull? Yes | No
    Hi,
    I know this is old post but i want to add PHP CURL example in this post.
    I hope this post is useful for all members.

    What is CURL?
    cURL is a PHP extension, that allows us to receive and send information via the URL syntax. By doing so, cURL makes it easy to communicate between different websites and domains.

    Code:
    <?php
    
    function _is_curl_installed() {
        if  (in_array  ('curl', get_loaded_extensions())) {
            return true;
        }
        else {
            return false;
        }
    }
    
    // Ouput text to user based on test
    if (_is_curl_installed()) {
      echo "cURL is <span style=\"color:blue\">installed</span> on this server <br><br><br>";
    } else {
      echo "cURL is NOT <span style=\"color:red\">installed</span> on this server";
    }
    
    
    function isExtensionLoaded($extension_name){
        return extension_loaded($extension_name);
    }
    echo isExtensionLoaded('curl');
    echo isExtensionLoaded('gd');
    
    
    
    echo " <br><br><br>";
    
    function nxs_cURLTest($url, $msg, $testText){  
      $ch = curl_init(); 
      curl_setopt($ch, CURLOPT_URL, $url); 
      curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36"); 
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
      curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
      $response = curl_exec($ch); 
      $errmsg = curl_error($ch); 
      $cInfo = curl_getinfo($ch); 
      curl_close($ch); 
      echo "Testing ... ".$url." - ".$cInfo['url']."<br />";
      if (stripos($response, $testText)!==false) 
        echo "....".$msg." - OK<br />"; 
      else 
      { 
        echo "....<b style='color:red;'>".$msg." - Problem</b><br /><pre>"; 
        print_r($errmsg); 
        print_r($cInfo); 
        print_r(htmlentities($response)); 
        echo "</pre>There is a problem with cURL. You need to contact your server admin or hosting provider.";
      }
    }
      nxs_cURLTest("http://rediff.com", "HTTP to Rediff", "REDIFF");
    
    echo " <br><br><br>";
    echo phpinfo();
    
    ?>
    Last edited by kumkum; 08-26-2020 at 04:27 PM. Reason: I want to add example

  7. #7


    Is this useful / helpfull? Yes | No
    Quote Originally Posted by kumkum View Post
    Hi,
    I know this is old post but i want to add PHP CURL example in this post.
    I hope this post is useful for all members.

    What is CURL?
    cURL is a PHP extension, that allows us to receive and send information via the URL syntax. By doing so, cURL makes it easy to communicate between different websites and domains.

    Code:
    <?php
    
    function _is_curl_installed() {
        if  (in_array  ('curl', get_loaded_extensions())) {
            return true;
        }
        else {
            return false;
        }
    }
    
    // Ouput text to user based on test
    if (_is_curl_installed()) {
      echo "cURL is <span style=\"color:blue\">installed</span> on this server <br><br><br>";
    } else {
      echo "cURL is NOT <span style=\"color:red\">installed</span> on this server";
    }
    
    
    function isExtensionLoaded($extension_name){
        return extension_loaded($extension_name);
    }
    echo isExtensionLoaded('curl');
    echo isExtensionLoaded('gd');
    
    
    
    echo " <br><br><br>";
    
    function nxs_cURLTest($url, $msg, $testText){  
      $ch = curl_init(); 
      curl_setopt($ch, CURLOPT_URL, $url); 
      curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36"); 
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
      curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
      $response = curl_exec($ch); 
      $errmsg = curl_error($ch); 
      $cInfo = curl_getinfo($ch); 
      curl_close($ch); 
      echo "Testing ... ".$url." - ".$cInfo['url']."<br />";
      if (stripos($response, $testText)!==false) 
        echo "....".$msg." - OK<br />"; 
      else 
      { 
        echo "....<b style='color:red;'>".$msg." - Problem</b><br /><pre>"; 
        print_r($errmsg); 
        print_r($cInfo); 
        print_r(htmlentities($response)); 
        echo "</pre>There is a problem with cURL. You need to contact your server admin or hosting provider.";
      }
    }
      nxs_cURLTest("http://rediff.com", "HTTP to Rediff", "REDIFF");
    
    echo " <br><br><br>";
    echo phpinfo();
    
    ?>
    You can check CURL complete example.

+ Post New Thread

Similar Threads

  1. Replies: 0
    Last Post: 09-28-2019, 10:21 AM
  2. Causes of the: Curl Error: 28 - Connection timed out after 100001 milliseconds
    By Fli in forum HTML,CSS, Javascript Coding & Programming
    Replies: 0
    Last Post: 04-12-2017, 07:59 AM
  3. Replies: 0
    Last Post: 09-14-2013, 08:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
 Protected by : ZB BLOCK  &  StopForumSpam