PHP  

What is the cURL in PHP❓

In the name of God

Hi there! I'm here to teach you how can you use cURL in PHP, but first we must know some words.

1. What is the cURL

The PHP Client URL (cURL) is a useful extension for Back-End developers that allows developers that can connect they're website to other websites (Like REST APIs).

2. Prerequisites

Just an application like WAMPP, XAMPP, AMPPS etc and a PC (A Computer or Laptop).

3. How can I use cURL in PHP

At first, we must creating a session for our cURL and store it in a constant or variable.

$curl = curl_init();

Then, we can do everything with cURL!

When our works with cURL done, we must close session that we store that in a variable/constant.

curl_close($curl);

It's easy! Yeah?

But here, we have a very very important function of cURL.

curl_setopt(sessionName, option, value); 

This is you and this is curl_setopt! Yeahhh! It's obvious from it's name that what it does for us!

 curl_setopt will set options of cURL

  • First Parameter: Session name that we store it in variable/const
  • Second: Option name
  • Third: value of option

Like this code

curl_setopt($curl, CURLOPT_URL, "https://c-sharpcorner.com);

This will set our target URL!

I think that it's enough for now! I will see you later, with better courses, articles and etc.

I hope you enjoy! Good Bye!