xref: /PHP-8.1/ext/standard/tests/array/compact.phpt (revision f5139878)
1--TEST--
2compact()
3--FILE--
4<?php
5
6$çity  = "San Francisco";
7$state = "CA";
8$event = "SIGGRAPH";
9
10$location_vars = array("c\\u0327ity", "state");
11
12$result = compact("event", $location_vars);
13var_dump($result);
14
15$result = compact(true);
16$foo = 'bar';
17$bar = 'baz';
18$result = compact($foo, [42]);
19var_dump($result);
20
21?>
22--EXPECTF--
23Warning: compact(): Undefined variable $c\u0327ity in %s on line %d
24array(2) {
25  ["event"]=>
26  string(8) "SIGGRAPH"
27  ["state"]=>
28  string(2) "CA"
29}
30
31Warning: compact(): Argument #1 must be string or array of strings, bool given in %s on line %d
32
33Warning: compact(): Argument #2 must be string or array of strings, int given in %s on line %d
34array(1) {
35  ["bar"]=>
36  string(3) "baz"
37}