xref: /PHP-5.3/Zend/tests/offset_string.phpt (revision ff593514)
1--TEST--
2using different variables to access string offsets
3--FILE--
4<?php
5
6$str = "Sitting on a corner all alone, staring from the bottom of his soul";
7
8var_dump($str[1]);
9var_dump($str[0.0836]);
10var_dump($str[NULL]);
11var_dump($str["run away"]);
12
13var_dump($str[TRUE]);
14var_dump($str[FALSE]);
15
16$fp = fopen(__FILE__, "r");
17var_dump($str[$fp]);
18
19$obj = new stdClass;
20var_dump($str[$obj]);
21
22$arr = Array(1,2,3);
23var_dump($str[$arr]);
24
25echo "Done\n";
26?>
27--EXPECTF--
28string(1) "i"
29string(1) "S"
30string(1) "S"
31string(1) "S"
32string(1) "i"
33string(1) "S"
34
35Warning: Illegal offset type in %s on line %d
36string(1) "%s"
37
38Warning: Illegal offset type in %s on line %d
39
40Notice: Object of class stdClass could not be converted to int in %s on line %d
41string(1) "%s"
42
43Warning: Illegal offset type in %s on line %d
44string(1) "i"
45Done
46