xref: /PHP-7.2/Zend/tests/str_offset_003.phpt (revision 370b7039)
1--TEST--
2string offset 003
3--FILE--
4<?php
5// Test negative string offsets
6
7function foo($x) {
8	var_dump($x);
9}
10
11$str = "abcdef";
12var_dump($str[-10]);
13var_dump($str[-3]);
14var_dump($str[2][-2]);
15var_dump($str[2][-1]);
16
17foo($str[-10]);
18foo($str[-3]);
19foo($str[2][-2]);
20foo($str[2][-1]);
21?>
22--EXPECTF--
23Notice: Uninitialized string offset: -10 in %sstr_offset_003.php on line %d
24string(0) ""
25string(1) "d"
26
27Notice: Uninitialized string offset: -2 in %sstr_offset_003.php on line %d
28string(0) ""
29string(1) "c"
30
31Notice: Uninitialized string offset: -10 in %sstr_offset_003.php on line %d
32string(0) ""
33string(1) "d"
34
35Notice: Uninitialized string offset: -2 in %sstr_offset_003.php on line %d
36string(0) ""
37string(1) "c"
38