source: src/router/php7/Zend/tests/list_keyed_evaluation_order_2.phpt @ 31874

Last change on this file since 31874 was 31874, checked in by brainslayer, 3 months ago

update php

File size: 1.3 KB
Line 
1--TEST--
2list() with keys, evaluation order #2
3--FILE--
4<?php
5
6// All the following should print 'a' then 'b'
7
8list($a, $b) = ['a', 'b'];
9var_dump($a);
10var_dump($b);
11
12list(0 => $a, 1 => $b) = ['a', 'b'];
13var_dump($a);
14var_dump($b);
15
16list(1 => $b, 0 => $a) = ['a', 'b'];
17var_dump($a);
18var_dump($b);
19
20$arr = [];
21list($arr[], $arr[]) = ['a', 'b'];
22var_dump($arr[0]);
23var_dump($arr[1]);
24
25$arr = [];
26list(0 => $arr[], 1 => $arr[]) = ['a', 'b'];
27var_dump($arr[0]);
28var_dump($arr[1]);
29
30$arr = [];
31list(1 => $arr[], 0 => $arr[]) = ['b', 'a'];
32var_dump($arr[0]);
33var_dump($arr[1]);
34
35$arr = [];
36list(list(1 => $arr[], 0 => $arr[])) = [['b', 'a']];
37var_dump($arr[0]);
38var_dump($arr[1]);
39
40$arr = [];
41list('key1' => $arr[], 'key2' => $arr[]) = ['key2' => 'b', 'key1' => 'a'];
42var_dump($arr[0]);
43var_dump($arr[1]);
44
45// This should print 'foo'
46$a = 0;
47list($a => $a) = ['foo', 'bar'];
48var_dump($a);
49
50// This should print 'bar' then 'foo'
51$a = 0;
52$b = 1;
53list($b => $a, $a => $c) = ['bar' => 'foo', 1 => 'bar'];
54var_dump($a);
55var_dump($c);
56
57?>
58--EXPECT--
59string(1) "a"
60string(1) "b"
61string(1) "a"
62string(1) "b"
63string(1) "a"
64string(1) "b"
65string(1) "a"
66string(1) "b"
67string(1) "a"
68string(1) "b"
69string(1) "a"
70string(1) "b"
71string(1) "a"
72string(1) "b"
73string(1) "a"
74string(1) "b"
75string(3) "foo"
76string(3) "bar"
77string(3) "foo"
Note: See TracBrowser for help on using the repository browser.