php-guzzleHow to add an application/x-www-form-urlencoded header in PHP Guzzle?
Adding an application/x-www-form-urlencoded header in PHP Guzzle can be done using the setHeader
method.
Example code
$client = new \GuzzleHttp\Client();
$client->setHeader('Content-Type', 'application/x-www-form-urlencoded');
The code above creates a new Guzzle client and sets the header Content-Type
to application/x-www-form-urlencoded
.
Code explanation
$client = new \GuzzleHttp\Client();
- creates a new Guzzle client$client->setHeader('Content-Type', 'application/x-www-form-urlencoded');
- sets the headerContent-Type
toapplication/x-www-form-urlencoded
Helpful links
More of Php Guzzle
- How to set a user agent in PHP Guzzle?
- How to set a timeout for a request with PHP Guzzle?
- How to add an SSL certificate to a request with PHP Guzzle?
- How to handle a RequestException with PHP Guzzle?
- How to make an asynchronous send with PHP Guzzle?
- How to convert a response to an array with PHP Guzzle?
- What version of PHP is required for Guzzle?
- How to make HTTP request with PHP Guzzle?
- How to stream with PHP Guzzle?
- How to troubleshoot cURL error 60 with Guzzle in PHP?
See more codes...