Skip to content

Commit c86e86d

Browse files
committed
Fix php-curl-class#428: Add custom request example
1 parent 9cae335 commit c86e86d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

examples/custom.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
require __DIR__ . '/vendor/autoload.php';
3+
4+
use \Curl\Curl;
5+
6+
7+
$curl = new Curl();
8+
$curl->setOpt(CURLOPT_CUSTOMREQUEST, 'GET');
9+
$curl->setOpt(CURLOPT_NOBODY, true);
10+
$curl->setOpt(CURLOPT_HEADER, true);
11+
$curl->setUrl('https://httpbin.org/get');
12+
$curl->exec();
13+
14+
if ($curl->error) {
15+
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
16+
} else {
17+
echo 'Response:' . "\n";
18+
var_dump($curl->response);
19+
}

0 commit comments

Comments
 (0)