ItSolutionStuff.com

PHP Curl Get Request with Parameters Example

By Hardik Savani • May 14, 2024
PHP

This simple article demonstrates of php curl get request with parameters example. This article goes in detailed on php curl get request example. it's simple example of php curl get request with params. it's simple example of curl get request php example. Let's get started with curl http request php.

In this tutorial, i will give you very simple example of how to send get curl request with parameters in php. so, let's see bellow example with output:

Example:

<?php

$ch = curl_init();

$url = "https://api.mywebtuts.com/api/users";

$dataArray = ['page' => 2];

$data = http_build_query($dataArray);

$getUrl = $url."?".$data;

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

curl_setopt($ch, CURLOPT_URL, $getUrl);

curl_setopt($ch, CURLOPT_TIMEOUT, 80);

$response = curl_exec($ch);

if(curl_error($ch)){

echo 'Request Error:' . curl_error($ch);

}else{

echo $response;

}

curl_close($ch);

?>

Output:

i hope it can help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Angular 12 CRUD Application Tutorial Example

Read Now →

Angular 12 Httpclient Service Request Example

Read Now →

Laravel Sanctum SPA API Authentication Example

Read Now →

Laravel 8 REST API with Passport Authentication Tutorial

Read Now →

Laravel 8 Import Export Excel and CSV File Tutorial

Read Now →

Laravel 8 Auth with Livewire Jetstream Tutorial

Read Now →

Codeigniter Curl Post Request with Parameters Example

Read Now →

PHP CURL Post Request with Parameters Example

Read Now →

Laravel Block/Whitelist IP Address Tutorial

Read Now →

Laravel CURL Request Example using Ixudra/curl

Read Now →

Laravel 5.2 API using JWT authentication tutorial from scratch example

Read Now →

PHP Download File from URL using CURL Request Example

Read Now →