xref: /php-src/tests/lang/bug22592.phpt (revision f8d79582)
1--TEST--
2Bug #22592 (cascading assignments to strings with curly braces broken)
3--FILE--
4<?php
5function error_hdlr($errno, $errstr) {
6    echo "[$errstr]\n";
7}
8
9set_error_handler('error_hdlr');
10
11$i = 4;
12$s = "string";
13
14$result = "* *-*";
15var_dump($result);
16$result[6] = '*';
17var_dump($result);
18$result[1] = $i;
19var_dump($result);
20$result[3] = $s;
21var_dump($result);
22$result[7] = 0;
23var_dump($result);
24$a = $result[1] = $result[3] = '-';
25var_dump($result);
26$b = $result[3] = $result[5] = $s;
27var_dump($result);
28$c = $result[0] = $result[2] = $result[4] = $i;
29var_dump($result);
30$d = $result[6] = $result[8] = 5;
31var_dump($result);
32$e = $result[1] = $result[6];
33var_dump($result);
34var_dump($a, $b, $c, $d, $e);
35$result[0] = $result[-4] = $result[-1] = 'a';
36var_dump($result);
37?>
38--EXPECT--
39string(5) "* *-*"
40string(7) "* *-* *"
41string(7) "*4*-* *"
42[Only the first byte will be assigned to the string offset]
43string(7) "*4*s* *"
44string(8) "*4*s* *0"
45string(8) "*-*-* *0"
46[Only the first byte will be assigned to the string offset]
47string(8) "*-*s*s*0"
48string(8) "4-4s4s*0"
49string(9) "4-4s4s505"
50string(9) "454s4s505"
51string(1) "-"
52string(1) "s"
53string(1) "4"
54string(1) "5"
55string(1) "5"
56string(9) "a54s4a50a"
57