xref: /PHP-7.0/Zend/tests/isset_str_offset.phpt (revision 327a5828)
1--TEST--
2Testing isset with string offsets
3--FILE--
4<?php
5
6print "- isset ---\n";
7
8$str = "test0123";
9
10var_dump(isset($str[-1]));
11var_dump(isset($str[0]));
12var_dump(isset($str[1]));
13var_dump(isset($str[4])); // 0
14var_dump(isset($str[5])); // 1
15var_dump(isset($str[8]));
16var_dump(isset($str[10000]));
17// non-numeric offsets
18print "- string ---\n";
19var_dump(isset($str['-1']));
20var_dump(isset($str['0']));
21var_dump(isset($str['1']));
22var_dump(isset($str['4'])); // 0
23var_dump(isset($str['1.5']));
24var_dump(isset($str['good']));
25var_dump(isset($str['3 and a half']));
26print "- bool ---\n";
27var_dump(isset($str[true]));
28var_dump(isset($str[false]));
29var_dump(isset($str[false][true]));
30print "- null ---\n";
31var_dump(isset($str[null]));
32print "- double ---\n";
33var_dump(isset($str[-1.1]));
34var_dump(isset($str[-0.8]));
35var_dump(isset($str[-0.1]));
36var_dump(isset($str[0.2]));
37var_dump(isset($str[0.9]));
38var_dump(isset($str[M_PI]));
39var_dump(isset($str[100.5001]));
40print "- array ---\n";
41var_dump(isset($str[array()]));
42var_dump(isset($str[array(1,2,3)]));
43print "- object ---\n";
44var_dump(isset($str[new stdClass()]));
45print "- resource ---\n";
46$f = fopen(__FILE__, 'r');
47var_dump(isset($str[$f]));
48print "done\n";
49
50?>
51--EXPECTF--
52- isset ---
53bool(false)
54bool(true)
55bool(true)
56bool(true)
57bool(true)
58bool(false)
59bool(false)
60- string ---
61bool(false)
62bool(true)
63bool(true)
64bool(true)
65bool(false)
66bool(false)
67bool(false)
68- bool ---
69bool(true)
70bool(true)
71bool(false)
72- null ---
73bool(true)
74- double ---
75bool(false)
76bool(true)
77bool(true)
78bool(true)
79bool(true)
80bool(true)
81bool(false)
82- array ---
83bool(false)
84bool(false)
85- object ---
86bool(false)
87- resource ---
88bool(false)
89done
90