xref: /PHP-7.1/ext/curl/tests/curl_basic_004.phpt (revision 7af945e2)
1--TEST--
2Test curl_opt() function with setting referer
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 setting referer ***' . "\n";
21
22  $url = "{$host}/get.php?test=referer";
23  $ch = curl_init();
24
25  ob_start(); // start output buffering
26  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
27  curl_setopt($ch, CURLOPT_REFERER, 'http://www.refer.er');
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 setting referer ***
38string(19) "http://www.refer.er"
39===DONE===
40