PHP code for Curl Custom Headers Example
This PHP code snippet was generated automatically for the Curl Custom Headers example.<< Back to the Curl Custom Headers example
What is Curl?
Curl is a popular open-source command-line tool and cross-platform library (libcurl) for transferring data between servers, designed to work without user intervention. Curl can upload or download data using popular protocols including HTTP, HTTPS, SFTP, SCP, and FTP. Curl has built-in support for HTTP Cookies, SSL, proxies, certificate validation, user authentication and works on all modern platforms and hardware, including Linux, Windows, and macOS.
What is HTTP?
HTTP (Hypertext Transfer Protocol) is a protocol for exchanging data between multiple network devices that are used to transfer data between an HTTP client (browser or mobile application) and a server. Now the HTTP protocol is the most popular and primary communication method on the Internet. HTTP is built on messages called "request" and "response" based on the client-server architecture. Devices communicate with each other by sending HTTP requests and receiving HTTP responses.
What is Custom Headers?
HTTP headers allow clients to send information to the server and return data to the client. The headers are usually invisible to the end-user and are only visible to server soft and network administrators. Custom headers are intended to provide additional information related to the current request or response, or for troubleshooting purposes.
How to pass Custom HTTP Headers to Curl?
You can use the -H "header: value" command line option to pass custom headers to Curl. Below is an example of sending a custom HTTP header with Curl: