xref: /PHP-7.0/Zend/tests/str_offset_001.phpt (revision 1f4f33af)
1--TEST--
2string offset 001
3--FILE--
4<?php
5function foo($x) {
6	var_dump($x);
7}
8
9$str = "abc";
10var_dump($str[-1]);
11var_dump($str[0]);
12var_dump($str[1]);
13var_dump($str[2]);
14var_dump($str[3]);
15var_dump($str[1][0]);
16var_dump($str[2][1]);
17
18foo($str[-1]);
19foo($str[0]);
20foo($str[1]);
21foo($str[2]);
22foo($str[3]);
23foo($str[1][0]);
24foo($str[2][1]);
25?>
26--EXPECTF--
27Notice: Uninitialized string offset: -1 in %sstr_offset_001.php on line %d
28string(0) ""
29string(1) "a"
30string(1) "b"
31string(1) "c"
32
33Notice: Uninitialized string offset: 3 in %sstr_offset_001.php on line %d
34string(0) ""
35string(1) "b"
36
37Notice: Uninitialized string offset: 1 in %sstr_offset_001.php on line %d
38string(0) ""
39
40Notice: Uninitialized string offset: -1 in %sstr_offset_001.php on line %d
41string(0) ""
42string(1) "a"
43string(1) "b"
44string(1) "c"
45
46Notice: Uninitialized string offset: 3 in %sstr_offset_001.php on line %d
47string(0) ""
48string(1) "b"
49
50Notice: Uninitialized string offset: 1 in %sstr_offset_001.php on line %d
51string(0) ""
52