xref: /PHP-7.3/Zend/tests/list_005.phpt (revision e97d5fab)
1--TEST--
2Testing list() with several variables
3--FILE--
4<?php
5
6$str = "foo";
7
8list($a, $b, $c) = $str;
9
10var_dump($a, $b, $c);
11
12print "----\n";
13
14$int = 1;
15
16list($a, $b, $c) = $int;
17
18var_dump($a, $b, $c);
19
20print "----\n";
21
22$obj = new stdClass;
23
24list($a, $b, $c) = $obj;
25
26var_dump($a, $b, $c);
27
28print "----\n";
29
30$arr = array(1, 2, 3);
31
32list($a, $b, $c) = $arr;
33
34var_dump($a, $b, $c);
35
36?>
37--EXPECTF--
38NULL
39NULL
40NULL
41----
42NULL
43NULL
44NULL
45----
46
47Fatal error: Uncaught Error: Cannot use object of type stdClass as array in %s:%d
48Stack trace:
49#0 {main}
50  thrown in %s on line %d
51