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