summaryrefslogtreecommitdiff
path: root/tests/strings/offsets_general.phpt
blob: b2ceea088a2f56929461fab7f84364c2f698a47a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--TEST--
testing the behavior of string offsets
--FILE--
<?php
$string = "foobar";
const FOO = "BAR"[0];
var_dump(FOO);
var_dump($string[0]);
var_dump($string[1]);
var_dump(isset($string[0]));
var_dump(isset($string[0][0]));
var_dump($string["foo"]);
var_dump(isset($string["foo"]["bar"]));

const FOO_DEPRECATED = "BAR"{0};
var_dump(FOO_DEPRECATED);
var_dump([$string{0}]); // 1 notice
var_dump($string{1});
var_dump(isset($string{0}));
var_dump(isset($string{0}{0})); // 2 notices
var_dump($string{"foo"});
var_dump(isset($string{"foo"}{"bar"})); // 2 notices
?>
--EXPECTF--

Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d

Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d

Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d

Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d

Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d

Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d

Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d

Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d

Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
string(1) "B"
string(1) "f"
string(1) "o"
bool(true)
bool(true)

Warning: Illegal string offset 'foo' in %s line %d
string(1) "f"
bool(false)
string(1) "B"
array(1) {
  [0]=>
  string(1) "f"
}
string(1) "o"
bool(true)
bool(true)

Warning: Illegal string offset 'foo' in %s line %d
string(1) "f"
bool(false)