1--TEST--
2setcookie() array variant error tests
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7
8ob_start();
9
10// Unrecognized key and no valid keys
11setcookie('name', 'value', ['unknown_key' => 'only']);
12// Numeric key and no valid keys
13setcookie('name2', 'value2', [0 => 'numeric_key']);
14// Unrecognized key
15setcookie('name3', 'value3', ['path' => '/path/', 'foo' => 'bar']);
16// Arguments after options array (will not be set)
17setcookie('name4', 'value4', [], "path", "domain.tld", true, true);
18
19var_dump(headers_list());
20--EXPECTHEADERS--
21
22--EXPECTF--
23Warning: setcookie(): Unrecognized key 'unknown_key' found in the options array in %s
24
25Warning: setcookie(): No valid options were found in the given array in %s
26
27Warning: setcookie(): Numeric key found in the options array in %s
28
29Warning: setcookie(): No valid options were found in the given array in %s
30
31Warning: setcookie(): Unrecognized key 'foo' found in the options array in %s
32
33Warning: setcookie(): Cannot pass arguments after the options array in %s
34array(4) {
35  [0]=>
36  string(%d) "X-Powered-By: PHP/%s"
37  [1]=>
38  string(22) "Set-Cookie: name=value"
39  [2]=>
40  string(24) "Set-Cookie: name2=value2"
41  [3]=>
42  string(37) "Set-Cookie: name3=value3; path=/path/"
43}
44