Annotation of embedaddon/php/Zend/tests/offset_string.phpt, revision 1.1.1.3
1.1 misho 1: --TEST--
2: using 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:
8: var_dump($str[1]);
9: var_dump($str[0.0836]);
10: var_dump($str[NULL]);
11: var_dump($str["run away"]);
1.1.1.2 misho 12: var_dump($str["13"]);
13: var_dump($str["14.5"]);
14: var_dump($str["15 and then some"]);
1.1 misho 15:
16: var_dump($str[TRUE]);
17: var_dump($str[FALSE]);
18:
19: $fp = fopen(__FILE__, "r");
20: var_dump($str[$fp]);
21:
22: $obj = new stdClass;
23: var_dump($str[$obj]);
24:
25: $arr = Array(1,2,3);
26: var_dump($str[$arr]);
27:
28: echo "Done\n";
29: ?>
1.1.1.2 misho 30: --EXPECTF--
1.1 misho 31: string(1) "i"
1.1.1.2 misho 32:
1.1.1.3 ! misho 33: Notice: String offset cast occurred in %s on line %d
1.1 misho 34: string(1) "S"
1.1.1.2 misho 35:
1.1.1.3 ! misho 36: Notice: String offset cast occurred in %s on line %d
1.1 misho 37: string(1) "S"
1.1.1.2 misho 38:
39: Warning: Illegal string offset 'run away' in %s on line %d
1.1 misho 40: string(1) "S"
1.1.1.2 misho 41: string(1) "c"
42:
43: Warning: Illegal string offset '14.5' in %s on line %d
44: string(1) "o"
45:
46: Notice: A non well formed numeric value encountered in %s on line %d
47: string(1) "r"
48:
1.1.1.3 ! misho 49: Notice: String offset cast occurred in %s on line %d
1.1 misho 50: string(1) "i"
1.1.1.2 misho 51:
1.1.1.3 ! misho 52: Notice: String offset cast occurred in %s on line %d
1.1 misho 53: string(1) "S"
54:
55: Warning: Illegal offset type in %s on line %d
56: string(1) "%s"
57:
58: Warning: Illegal offset type in %s on line %d
59:
60: Notice: Object of class stdClass could not be converted to int in %s on line %d
61: string(1) "%s"
62:
63: Warning: Illegal offset type in %s on line %d
64: string(1) "i"
1.1.1.2 misho 65: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>