xref: /PHP-8.0/Zend/tests/str_offset_003.phpt (revision d30cd7d7)
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--
23Warning: Uninitialized string offset -10 in %s on line %d
24string(0) ""
25string(1) "d"
26
27Warning: Uninitialized string offset -2 in %s on line %d
28string(0) ""
29string(1) "c"
30
31Warning: Uninitialized string offset -10 in %s on line %d
32string(0) ""
33string(1) "d"
34
35Warning: Uninitialized string offset -2 in %s on line %d
36string(0) ""
37string(1) "c"
38