xref: /PHP-5.5/Zend/tests/bug39018.phpt (revision 77566edb)
1--TEST--
2Bug #39018 (Error control operator '@' fails to suppress "Uninitialized string offset")
3--FILE--
4<?php
5
6error_reporting(E_ALL);
7
8$a = 'foo';
9$a[111111111111111111111];
10
11$a = '';
12
13$a[0];
14
15print $a[0]; // 12
16
17$a[-11111111111111111111111];
18
19print $a[-11111111111111111111111]; // 16
20
21$a[-0];
22
23$x = 'test';
24
25@$x[4];
26
27@$y = $x[4];
28
29@('a' == $x[4]);
30
31$x[4] == 'a'; // 28
32
33@$x[4] == 'a';
34
35(@$x[4]) == 'a';
36
37($x[4]) == 'a'; // 34
38
39(@($x[4])) == 'a';
40
41(($x[4])) == 'a'; // 38
42
43@($x[4]) == 'a';
44
45($x[4]) == 'a'; // 42
46
47@($x[4] == 'a');
48
49($x[4] == 'a'); // 46
50
51$y = 'foobar';
52
53$y[12.2];
54
55print $y[12.2]; // 52
56
57$y[3.5];
58
59print $y[3.5]; // 56
60
61print "\nDone\n";
62
63?>
64--EXPECTF--
65Notice: String offset cast occurred in %s on line %d
66
67Notice: Uninitialized string offset: %s in %s on line 6
68
69Notice: Uninitialized string offset: 0 in %s on line %d
70
71Notice: Uninitialized string offset: 0 in %s on line %d
72
73Notice: String offset cast occurred in %s on line %d
74
75Notice: Uninitialized string offset: %i in %s on line %d
76
77Notice: String offset cast occurred in %s on line %d
78
79Notice: Uninitialized string offset: %i in %s on line %d
80
81Notice: Uninitialized string offset: 0 in %s on line %d
82
83Notice: Uninitialized string offset: 4 in %s on line %d
84
85Notice: Uninitialized string offset: 4 in %s on line %d
86
87Notice: Uninitialized string offset: 4 in %s on line %d
88
89Notice: Uninitialized string offset: 4 in %s on line %d
90
91Notice: Uninitialized string offset: 4 in %s on line %d
92
93Notice: String offset cast occurred in %s on line %d
94
95Notice: Uninitialized string offset: 12 in %s on line %d
96
97Notice: String offset cast occurred in %s on line %d
98
99Notice: Uninitialized string offset: 12 in %s on line %d
100
101Notice: String offset cast occurred in %s on line %d
102
103Notice: String offset cast occurred in %s on line %d
104b
105Done
106