xref: /PHP-7.2/ext/curl/tests/curl_basic_005.phpt (revision 17ccbeec)
1--TEST--
2Test curl_opt() function with user agent
3--CREDITS--
4Sebastian Deutsch <sebastian.deutsch@9elements.com>
5TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
6--SKIPIF--
7<?php include 'skipif.inc'; ?>
8--FILE--
9<?php
10/* Prototype  : bool curl_setopt(resource ch, int option, mixed value)
11 * Description: Set an option for a cURL transfer
12 * Source code: ext/curl/interface.c
13 * Alias to functions:
14 */
15
16  include 'server.inc';
17  $host = curl_cli_server_start();
18
19  // start testing
20  echo '*** Testing curl with user agent ***' . "\n";
21
22  $url = "{$host}/get.php?test=useragent";
23  $ch = curl_init();
24
25  ob_start(); // start output buffering
26  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
27  curl_setopt($ch, CURLOPT_USERAGENT, 'cURL phpt');
28  curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
29
30  $curl_content = curl_exec($ch);
31  curl_close($ch);
32
33  var_dump( $curl_content );
34?>
35===DONE===
36--EXPECTF--
37*** Testing curl with user agent ***
38string(9) "cURL phpt"
39===DONE===
40