Technical interview questions for software engineers — languages, databases, web, cloud, DevOps, and fundamentals. Browse all topics.

  • PHP Interview Questions

  • OOP Interview Questions

  • jQuery Interview Questions

  • MySQL Interview Questions

  • JavaScript Interview Questions

  • HR Interview Questions

  • HTML Interview Questions

  • C/C++ Interview Questions

  • Showing posts with label curl functions. Show all posts
    Showing posts with label curl functions. Show all posts

    cURL Simple Example in PHP

    cURL Simple Example in PHP:


    cURL allows you to connect and communicate to many different types of servers with many different types of protocols.
    PHP Supports libcurl.

    Example:

    <?php
            // initialize curl session
            $ch = curl_init();
           
            curl_setopt($ch, CURLOPT_URL, "example.com");  // set url      
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//return the transfer as a string
            
            $output = curl_exec($ch);//output string


            // close curl session
            curl_close($ch);     
    ?>


    Bookmark and Share

    What is cURL in PHP?

    What is cURL in PHP?

    cURL allows you to connect and communicate to many different types of servers with many different types of protocols.
    PHP Supports libcurl.

    Requirements:
    In order to use PHP's cURL functions you need to install the libcurl package.PHP 5.0.0 requires a libcurl version 7.10.5 or greater.

    cURL Functions:
        curl_close : Close a cURL session.
        curl_errno: Return the last error number.
        curl_error: Return a string containing the last error for the current session.
        curl_exec: Perform a cURL session.
        curl_getinfo: Get information regarding a specific transfer.
        curl_init: Initialize a cURL session.
        curl_setopt_array: Set multiple options for a cURL transfer.
        curl_setopt: Set an option for a cURL transfer.
        curl_version: Gets cURL version information.


    Bookmark and Share